private void RunWorkers(int processesToUse, string name, bool workerInitiallyOwned, NPath waitFilePath, string grabberMode, NPath dataFile, Action afterStart = null) { var workers = new List <Process>(); try { for (var i = 0; i < processesToUse; i++) { workers.Add(StartWorkerProcess(name, workerInitiallyOwned, waitFilePath, grabberMode, dataFile)); } waitFilePath.Delete(); if (afterStart != null) { afterStart(); } CleanlyJoinAll(workers.ToArray()); } catch (Exception) { KillRemainingRunningWorkers(workers); throw; } }
private static void RecreateDagDirectoryIfNeeded(NPath dagDirectory) { var beeBackendInfoPath = dagDirectory.Combine("bee_backend.info"); var currentInfo = new BeeBackendInfo() { BeeBackendHash = BeeBackendHash, UnityVersion = Application.unityVersion }; var diskInfo = new BeeBackendInfo(); // Clear dag directory if it was produced with a different bee_backend, to avoid problem where bee_backend sometimes looses track of files. if (dagDirectory.Exists()) { if (beeBackendInfoPath.Exists()) { var contents = beeBackendInfoPath.ReadAllText(); EditorJsonUtility.FromJsonOverwrite(contents, diskInfo); // Note: We're clearing dag directory only when bee backend hash has changed, it's fine for Unity version to be different. // Unity version is used here for informational purposes, so we can clearly see from which Unity version the user was upgrading if (string.IsNullOrEmpty(diskInfo.BeeBackendHash) || !diskInfo.BeeBackendHash.Equals(currentInfo.BeeBackendHash)) { Console.WriteLine($"Clearing Bee directory '{dagDirectory}', since bee backend hash ('{beeBackendInfoPath}') is different, previous hash was {diskInfo.BeeBackendHash} (Unity version: {diskInfo.UnityVersion}), current hash is {currentInfo.BeeBackendHash} (Unity version: {currentInfo.UnityVersion})."); dagDirectory.Delete(); } } else { Console.WriteLine($"Clearing Bee directory '{dagDirectory}', since bee backend information ('{beeBackendInfoPath}') is missing."); dagDirectory.Delete(); } } dagDirectory.CreateDirectory(); // Update info, if at least of one the fields is different if (string.IsNullOrEmpty(diskInfo.BeeBackendHash) || string.IsNullOrEmpty(diskInfo.UnityVersion) || !diskInfo.BeeBackendHash.Equals(currentInfo.BeeBackendHash) || !diskInfo.UnityVersion.Equals(currentInfo.UnityVersion)) { beeBackendInfoPath.WriteAllText(EditorJsonUtility.ToJson(currentInfo, true)); } }
public static bool ForgivingCleanDirectory(NPath directory) { try { if (directory.Exists("")) { directory.Delete(DeleteMode.Normal); } return(true); } catch (Exception) { if (!directory.Files(true).Any <NPath>()) { return(true); } } return(false); }
public void TearDown() { _tempPath.Delete(); }
public void DeleteRelativePath() { var path = new NPath("mydir/myfile.txt"); Assert.Throws <ArgumentException>(() => path.Delete()); }
public void DeleteRelativePath() { var path = new NPath("mydir/myfile.txt"); Assert.Throws<ArgumentException>(() => path.Delete()); }
public void Dispose() { _path.Delete(); }
public void TearDown() { _tempPath.Delete(); NPath.FileSystem = null; }