public void LockFileCompletely(ulong dht, uint project, string path, ThreadedLinkedList <StorageItem> archived, List <LockError> errors) { if (archived.SafeCount == 0) { return; } StorageFile main = (StorageFile)archived.SafeFirst.Value; string dirpath = GetRootPath(dht, project) + path; // delete main file string finalpath = dirpath + Path.DirectorySeparatorChar + main.Name; if (File.Exists(finalpath)) { if (DeleteFile(finalpath, errors, false)) { main.RemoveFlag(StorageFlags.Unlocked); } } // delete archived file finalpath = dirpath + Path.DirectorySeparatorChar + ".history" + Path.DirectorySeparatorChar; if (Directory.Exists(finalpath)) { List <string> stillLocked = new List <string>(); archived.LockReading(delegate() { foreach (StorageFile file in archived) { string historyPath = finalpath + GetHistoryName(file); if (File.Exists(historyPath)) { if (DeleteFile(historyPath, errors, false)) { file.RemoveFlag(StorageFlags.Unlocked); } else { stillLocked.Add(historyPath); } } } }); // delete history folder DeleteFolder(finalpath, errors, stillLocked); } }
public bool IsHistoryUnlocked(ulong dht, uint project, string path, ThreadedLinkedList <StorageItem> archived) { string finalpath = GetRootPath(dht, project) + path + Path.DirectorySeparatorChar + ".history" + Path.DirectorySeparatorChar; bool result = false; if (Directory.Exists(finalpath)) { archived.LockReading(delegate() { foreach (StorageFile file in archived) { if (File.Exists(finalpath + GetHistoryName(file))) { result = true; break; } } }); } return(result); }
public void LockFileCompletely(ulong dht, uint project, string path, ThreadedLinkedList<StorageItem> archived, List<LockError> errors) { if (archived.SafeCount == 0) return; StorageFile main = (StorageFile) archived.SafeFirst.Value; string dirpath = GetRootPath(dht, project) + path; // delete main file string finalpath = dirpath + Path.DirectorySeparatorChar + main.Name; if (File.Exists(finalpath)) if (DeleteFile(finalpath, errors, false)) main.RemoveFlag(StorageFlags.Unlocked); // delete archived file finalpath = dirpath + Path.DirectorySeparatorChar + ".history" + Path.DirectorySeparatorChar; if (Directory.Exists(finalpath)) { List<string> stillLocked = new List<string>(); archived.LockReading(delegate() { foreach (StorageFile file in archived) { string historyPath = finalpath + GetHistoryName(file); if (File.Exists(historyPath)) if (DeleteFile(historyPath, errors, false)) file.RemoveFlag(StorageFlags.Unlocked); else stillLocked.Add(historyPath); } }); // delete history folder DeleteFolder(finalpath, errors, stillLocked); } }
public bool IsHistoryUnlocked(ulong dht, uint project, string path, ThreadedLinkedList<StorageItem> archived) { string finalpath = GetRootPath(dht, project) + path + Path.DirectorySeparatorChar + ".history" + Path.DirectorySeparatorChar; bool result = false; if (Directory.Exists(finalpath)) archived.LockReading(delegate() { foreach (StorageFile file in archived) if (File.Exists(finalpath + GetHistoryName(file))) { result = true; break; } }); return result; }