diff --git a/.vs/DataOrganizer/v16/.suo b/.vs/DataOrganizer/v16/.suo index 0880bae..b70aa90 100644 Binary files a/.vs/DataOrganizer/v16/.suo and b/.vs/DataOrganizer/v16/.suo differ diff --git a/DataOrganizer/FileViewer.cs b/DataOrganizer/FileViewer.cs index 5639f24..472f9e2 100644 --- a/DataOrganizer/FileViewer.cs +++ b/DataOrganizer/FileViewer.cs @@ -171,13 +171,11 @@ namespace DataOrganizer var snapShot = new Snapshot(files, folderGroup); ActiveSnapshotForPrimaryTree.MergeSnapshot(snapShot); - var newFiles = snapShot.Files.Values.Except(ActiveSnapshotForPrimaryTree.Files.Values); - var existingFiles = ActiveSnapshotForPrimaryTree.Files.Values.Except(snapShot.Files.Values); var newFilesCount = 0; var modifiedFilesCount = 0; var deletedFilesCount = 0; - foreach(var f in newFiles) + foreach(var f in ActiveSnapshotForPrimaryTree.Files.Values.Where(x => x.Status == FileSnapshot.FileStatus.PendingInsert))//newFiles) { var newNode = new TreeNode(f.Name) { Name = f.FullPath, BackColor = Color.LightBlue, ToolTipText = "New File Found!" }; var folders = ProcessFileFolders(f); diff --git a/DataOrganizer/Snapshot.cs b/DataOrganizer/Snapshot.cs index 0d501ae..799da53 100644 --- a/DataOrganizer/Snapshot.cs +++ b/DataOrganizer/Snapshot.cs @@ -167,44 +167,47 @@ namespace DataOrganizer public void MergeSnapshot(Snapshot snapshot) { - //TODO: build this out - var newFiles = Files.Values.Except(snapshot.Files.Values); - var newFolders = Directories.Values.Except(snapshot.Directories.Values); - var newOrgFolders = OrganizationFolders.Values.Except(snapshot.OrganizationFolders.Values); + var newFiles = new List(); var existingFiles = Files.Values.Except(snapshot.Files.Values); + foreach(var file in snapshot.Files) + if (!Files.ContainsKey(file.Key)) newFiles.Add(file.Value); + + foreach (var folder in snapshot.OrganizationFolders) + { + if (!OrganizationFolders.ContainsKey(folder.Key) && folder.Key != Root.FullPath) + { + Root.AddDirectory(snapshot.Directories[folder.Key]); + OrganizationFolders.Add(folder.Key, new List()); + } + } + foreach (var existingFile in existingFiles) { if (!snapshot.Files.ContainsKey(existingFile.FullPath)) { existingFile.Status = FileSnapshot.FileStatus.PendingDelete; - //deletedFiles.Add(existingFile); - //pendingChanges++; } else if (existingFile.ModifiedDate != snapshot.Files[existingFile.FullPath].ModifiedDate) { existingFile.ModifiedDate = snapshot.Files[existingFile.FullPath].ModifiedDate; - //modifiedFiles.Add(snapShot.Files[existingFile.FullPath]); - //pendingChanges++; } } foreach(var newFile in newFiles) { - if(!Files.ContainsKey(newFile.FullPath)) Files.Add(newFile.FullPath, newFile); + Files.Add(newFile.FullPath, newFile); Folder folder = newFile.ParentFolder; while(folder != null) { if (!Directories.ContainsKey(folder.FullPath)) - { Directories.Add(folder.FullPath, folder); - } - - if (folder.Parent == null && !OrganizationFolders.ContainsKey(folder.FullPath)) OrganizationFolders.Add(folder.FullPath, folder.Files.Values.ToList()); folder = folder.Parent; } + + OrganizationFolders[newFile.OrganizationalFolder.FullPath].Add(newFile); } }