void AddNewFolder(FolderNode folder) { // if no changes then temp local, add path if (folder.Changes.Count == 0) Working.TrackFolder(folder.GetPath()); // add through working path // if 1 change, then file is remote, add item else if (folder.Changes.Count == 1) Working.TrackFolder(folder.GetPath(), (StorageFolder)GetFirstItem(folder.Changes)); // if more than 1 change, them multiple remotes else if (folder.Changes.Count > 1) MessageBox.Show("Select specific folder from changes below to add"); }
public void LockFolder(FolderNode folder, bool subs, List<LockError> errors) { string path = folder.GetPath(); string wholepath = Storages.GetRootPath(UserID, ProjectID) + path; List<string> stillLocked = new List<string>(); foreach (FileItem file in folder.Files.Values) if (!file.Temp) { Storages.LockFileCompletely(UserID, ProjectID, path, file.Archived, errors); string filepath = wholepath + Path.DirectorySeparatorChar + file.Details.Name; if (File.Exists(filepath)) stillLocked.Add(filepath); } folder.Details.RemoveFlag(StorageFlags.Unlocked); folder.Update(); if (subs) foreach (FolderNode subfolder in folder.Folders.Values) if (!subfolder.Temp) LockFolder(subfolder, subs, errors); Storages.DeleteFolder(wholepath, errors, stillLocked); }
public void UnlockFolder(FolderNode folder, bool subs, List<LockError> errors) { string path = folder.GetPath(); string root = Storages.GetRootPath(UserID, ProjectID); if(!Storages.CreateFolder(root + path, errors, subs)) return; if (Directory.Exists(root + path)) { // set flag folder.Details.SetFlag(StorageFlags.Unlocked); folder.Update(); // unlock files foreach (FileItem file in folder.Files.Values) if (!file.Temp && !file.Details.IsFlagged(StorageFlags.Archived)) Storages.UnlockFile(UserID, ProjectID, path, (StorageFile)file.Details, false, errors); // unlock subfolders if (subs) foreach (FolderNode subfolder in folder.Folders.Values) if (!subfolder.Details.IsFlagged(StorageFlags.Archived)) UnlockFolder(subfolder, subs, errors); } }
private void SelectFolder(FolderNode folder) { if (folder == null) return; /* * * if (!SelectedInfo.IsFile && SelectedInfo.CurrentFolder != null) { if (SelectedInfo.CurrentFolder.Details.UID == SelectedFolder.Details.UID) SelectedInfo.ShowItem(SelectedFolder, null); else SelectedInfo.ShowDefault(); } * */ bool infoSet = false; string infoPath = SelectedInfo.CurrentPath; SelectedFolder = folder; folder.Selected = true; string dirpath = null; if (Working != null) dirpath = Working.RootPath + folder.GetPath(); ulong selectedUID = 0; if (SelectedInfo.CurrentItem != null) selectedUID = SelectedInfo.CurrentItem.UID; FileListView.Items.Clear(); FileListView.SmallImageList = FileIcons; // add sub folders if (!FoldersButton.Checked && folder.Parent.GetType() == typeof(FolderNode)) { FileItem dots = new FileItem(this, new FolderNode(this, new StorageFolder(), folder.Parent, false)); dots.Folder.Details.Name = ".."; dots.Text = ".."; if (string.Compare("..", infoPath, true) == 0) { infoSet = true; dots.Selected = true; SelectedInfo.ShowDots(); } FileListView.Items.Add(dots); } foreach (FolderNode sub in folder.Nodes) { FileItem subItem = new FileItem(this, sub); if (string.Compare(sub.GetPath(), infoPath, true) == 0) { infoSet = true; subItem.Selected = true; SelectedInfo.ShowItem(sub, null); } FileListView.Items.Add(subItem); } // if folder unlocked, add untracked folders, mark temp if(folder.Details.IsFlagged(StorageFlags.Unlocked) && Directory.Exists(dirpath)) try { foreach (string dir in Directory.GetDirectories(dirpath)) { string name = Path.GetFileName(dir); if (name.CompareTo(".history") == 0) continue; if (folder.GetFolder(name) != null) continue; StorageFolder details = new StorageFolder(); details.Name = name; FileItem tempFolder = new FileItem(this, new FolderNode(this, details, folder, true)); if (string.Compare(tempFolder.GetPath(), infoPath, true) == 0) { infoSet = true; tempFolder.Selected = true; SelectedInfo.ShowItem(tempFolder.Folder, null); } FileListView.Items.Add(tempFolder); } } catch { } // add tracked files foreach (FileItem file in folder.Files.Values) if (!file.Details.IsFlagged(StorageFlags.Archived) || GhostsButton.Checked) { if (string.Compare(file.GetPath(), infoPath, true) == 0) { infoSet = true; file.Selected = true; SelectedInfo.ShowItem(folder, file); } else file.Selected = false; FileListView.Items.Add(file); } // if folder unlocked, add untracked files, mark temp if (folder.Details.IsFlagged(StorageFlags.Unlocked) && Directory.Exists(dirpath)) try { foreach (string filepath in Directory.GetFiles(dirpath)) { string name = Path.GetFileName(filepath); if (folder.GetFile(name) != null) continue; StorageFile details = new StorageFile(); details.Name = name; details.InternalSize = new FileInfo(filepath).Length; FileItem tempFile = new FileItem(this, folder, details, true); if (string.Compare(tempFile.GetPath(), infoPath, true) == 0) { infoSet = true; tempFile.Selected = true; SelectedInfo.ShowItem(folder, tempFile); } FileListView.Items.Add(tempFile); } } catch { } UpdateListItems(); if (!infoSet && SelectedFolder.GetPath() == infoPath) { infoSet = true; SelectedInfo.ShowItem(SelectedFolder, null); } if (!infoSet) SelectedInfo.ShowDiffs(); }