Changeset 4269 for branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/PluginCache.cs
- Timestamp:
- 08/20/10 09:54:05 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/PluginCache.cs
r4254 r4269 9 9 using HeuristicLab.PluginInfrastructure.Manager; 10 10 using HeuristicLab.Tracing; 11 using System.Reflection; 11 12 12 13 namespace HeuristicLab.Hive.Slave.Core { … … 15 16 private static PluginCache instance = null; 16 17 17 public const string PLUGIN_REPO = @"plugins\";18 public string PluginRepositoryDir { get; set; } 18 19 19 20 private List<PluginDescription> cachedPlugins = new List<PluginDescription>(); 20 21 21 private PluginManager pm = new PluginManager(PLUGIN_REPO);22 private PluginManager pm; 22 23 23 24 public static PluginCache Instance { … … 28 29 } 29 30 } 31 30 32 public PluginCache() { 33 PluginRepositoryDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins"); 34 35 this.pm = new PluginManager(PluginRepositoryDir); 31 36 DoUpdateRun(); 32 37 } 33 38 34 39 private void DoUpdateRun() { 40 if (!Directory.Exists(PluginRepositoryDir)) { 41 Directory.CreateDirectory(PluginRepositoryDir); 42 } 35 43 pm.DiscoverAndCheckPlugins(); 36 44 cachedPlugins = new List<PluginDescription>(pm.Plugins); 37 45 } 38 46 39 40 47 [MethodImpl(MethodImplOptions.Synchronized)] 41 48 public bool CopyPluginsForJob(List<HivePluginInfoDto> requests, Guid jobId) { 42 43 String targetDir = PLUGIN_REPO + jobId.ToString() + "\\"; 49 String targetDir = Path.Combine(PluginRepositoryDir, jobId.ToString()); 44 50 45 51 if (Directory.Exists(targetDir)) { … … 50 56 51 57 foreach (HivePluginInfoDto requestedPlugin in requests) { 52 PluginDescription pd = 53 cachedPlugins.Where( 54 cp => 55 cp.Name == requestedPlugin.Name && 56 cp.Version.Major == requestedPlugin.Version.Major && 57 cp.Version.Minor == requestedPlugin.Version.Minor && 58 cp.Version.Revision >= requestedPlugin.Version.Revision). 59 SingleOrDefault(); 58 PluginDescription pd = cachedPlugins.Where(cp => 59 cp.Name == requestedPlugin.Name && 60 cp.Version.Major == requestedPlugin.Version.Major && 61 cp.Version.Minor == requestedPlugin.Version.Minor && 62 cp.Version.Revision >= requestedPlugin.Version.Revision). 63 SingleOrDefault(); 60 64 if (pd == null) { 61 65 return false; … … 63 67 64 68 foreach (IPluginFile ipf in pd.Files) { 65 File.Copy(ipf.Name, targetDir + ipf.Name.Split('\\').Last()); 69 string x = targetDir + ipf.Name.Split('\\').Last(); 70 string y = Path.Combine(targetDir, Path.GetFileName(ipf.Name)); 71 72 //File.Copy(ipf.Name, targetDir + ipf.Name.Split('\\').Last()); 73 File.Copy(ipf.Name, Path.Combine(targetDir, Path.GetFileName(ipf.Name))); 66 74 } 67 75 } … … 113 121 Logger.Debug("creating new files"); 114 122 foreach (HivePluginFile pf in updateablePlugin.PluginFiles) { 115 File.WriteAllBytes(PLUGIN_REPO + pf.Name.Split('\\').Last(), pf.BinaryFile); 123 string x = PluginRepositoryDir + pf.Name.Split('\\').Last(); 124 string y = Path.Combine(PluginRepositoryDir, Path.GetFileName(pf.Name)); 125 File.WriteAllBytes(Path.Combine(PluginRepositoryDir, Path.GetFileName(pf.Name)), pf.BinaryFile); 116 126 } 117 127 … … 124 134 try { 125 135 Logger.Debug("unloading..."); 126 Directory.Delete(Path.Combine(PLUGIN_REPO, id.ToString()), true); 127 } catch (Exception ex) { 136 Directory.Delete(Path.Combine(PluginRepositoryDir, id.ToString()), true); 137 } 138 catch (Exception ex) { 128 139 Logger.Debug("failed while unloading " + id + " with exception " + ex); 129 140 }
Note: See TracChangeset
for help on using the changeset viewer.