示例#1
0
        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);
            }
        }
示例#2
0
        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 { }
        }
示例#3
0
        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 { }
        }