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 void LockFile(ulong dht, uint project, string path, StorageFile file, bool history) { string finalpath = GetRootPath(dht, project) + path; if (history) { finalpath += Path.DirectorySeparatorChar + ".history" + Path.DirectorySeparatorChar + GetHistoryName(file); } else { finalpath += Path.DirectorySeparatorChar + file.Name; } try { if (File.Exists(finalpath)) { File.Delete(finalpath); } file.RemoveFlag(StorageFlags.Unlocked); } catch { } }
public void LockFile(ulong dht, uint project, string path, StorageFile file, bool history) { string finalpath = GetRootPath(dht, project) + path; if (history) finalpath += Path.DirectorySeparatorChar + ".history" + Path.DirectorySeparatorChar + GetHistoryName(file); else finalpath += Path.DirectorySeparatorChar + file.Name; try { if (File.Exists(finalpath)) File.Delete(finalpath); file.RemoveFlag(StorageFlags.Unlocked); } catch { } }