Changeset 5787
- Timestamp:
- 03/22/11 12:46:37 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/PluginCache.cs
r5721 r5787 70 70 71 71 private void DoUpdateRun() { 72 if (!Directory.Exists(PluginCacheDir)) { 73 Directory.CreateDirectory(PluginCacheDir); 74 } 75 72 SafelyCreateDirectory(PluginCacheDir); 76 73 foreach (string dir in Directory.EnumerateDirectories(PluginCacheDir)) { 77 74 cachedPluginsGuids.Add(Guid.Parse(GetFilenameFromPath(dir))); // Todo: cleaner solution to getFilenameFromPath … … 85 82 String targetDir = Path.Combine(PluginTempBaseDir, jobId.ToString()); 86 83 87 if (Directory.Exists(targetDir)) { 88 Directory.Delete(targetDir, true); 89 } 90 Directory.CreateDirectory(targetDir); 84 RecreateDirectory(targetDir); 91 85 92 86 foreach (Plugin requestedPlugin in requests) { … … 116 110 } 117 111 112 private static DirectoryInfo RecreateDirectory(String targetDir) { 113 var di = new DirectoryInfo(targetDir); 114 if (di.Exists) Directory.Delete(targetDir, true); 115 di.Refresh(); 116 while (di.Exists) { 117 Thread.Sleep(50); 118 di.Refresh(); 119 } 120 return SafelyCreateDirectory(targetDir); 121 } 122 123 private static DirectoryInfo SafelyCreateDirectory(String targetDir) { 124 var di = new DirectoryInfo(targetDir); 125 if (!di.Exists) { 126 di = Directory.CreateDirectory(targetDir); 127 while (!di.Exists) { 128 Thread.Sleep(50); 129 di.Refresh(); 130 } 131 } 132 return di; 133 } 134 118 135 private void CopyFile(string baseDir, string targetDir, string fileName) { 119 136 if (!File.Exists(Path.Combine(targetDir, fileName))) File.Copy(Path.Combine(baseDir, fileName), Path.Combine(targetDir, fileName)); … … 164 181 165 182 //put all files belonging to a plugin in the same directory 166 if (!Directory.Exists(pluginDir)) { 167 DirectoryInfo di = Directory.CreateDirectory(pluginDir); 168 } 183 SafelyCreateDirectory(pluginDir); 169 184 File.WriteAllBytes(Path.Combine(pluginDir, Path.GetFileName(pluginData.FileName)), pluginData.Data); 170 185 }
Note: See TracChangeset
for help on using the changeset viewer.