diff --git a/.vs/DataOrganizer/v16/.suo b/.vs/DataOrganizer/v16/.suo index 2709873..0ce1a64 100644 Binary files a/.vs/DataOrganizer/v16/.suo and b/.vs/DataOrganizer/v16/.suo differ diff --git a/DataOrganizer/FileManager.Designer.cs b/DataOrganizer/FileManager.Designer.cs index 8def445..39c405b 100644 --- a/DataOrganizer/FileManager.Designer.cs +++ b/DataOrganizer/FileManager.Designer.cs @@ -379,6 +379,7 @@ this.ClientSize = new System.Drawing.Size(1306, 964); this.Controls.Add(this.MainLayoutPanel); this.Name = "FileManager"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "File Manager"; this.MainLayoutPanel.ResumeLayout(false); this.MainLayoutPanel.PerformLayout(); diff --git a/DataOrganizer/FileManager.cs b/DataOrganizer/FileManager.cs index ef014e1..c10b0ad 100644 --- a/DataOrganizer/FileManager.cs +++ b/DataOrganizer/FileManager.cs @@ -81,34 +81,46 @@ namespace DataOrganizer ComparisionSnapshot = new Snapshot(db.GetFilesForProfileByFolderGroup(p.Id, f.Id), f); var diff = ActiveSnapshot.Diff(ComparisionSnapshot); - //foreach (var folder in ActiveSnapshot.Directories.Values) - //{ - // if (ComparisionSnapshot.Directories.ContainsKey(folder.FullPath)) - // { - // renames.AddRange(ActiveSnapshot.FindFileRenames(folder, ComparisionSnapshot.Directories[folder.FullPath])); - // } - //} - - //foreach (var rename in renames) - //{ - // DiffViewTreeView.Nodes.Add($"From: {rename.From.Name}"); - // DiffViewTreeView.Nodes.Add($"To: {rename.To.Name}"); - //} - var dupCount = 0; - - foreach(var folder in ActiveSnapshot.TopLevelFolders.Keys) + foreach (var folder in ActiveSnapshot.Directories.Values) { - foreach(var dup in ActiveSnapshot.FindDuplicates(ActiveSnapshot.Directories[folder])) + if (!folder.IsRootFolder) { - var node = new TreeNode($"{dup.File.Name} ({dup.Duplicates.Count})") { ToolTipText = dup.File.FullPath }; - foreach(var d in dup.Duplicates) + var noRoot = folder.FullPath.Remove(0, ActiveSnapshot.Root.FullPath.Length + 1); + var w = Path.Combine(f.Path, noRoot); + + if (ComparisionSnapshot.Directories.ContainsKey(w)) { - node.Nodes.Add(new TreeNode(d.Name) { ToolTipText = d.FullPath }); - dupCount++; + renames.AddRange(ActiveSnapshot.FindFileRenames(folder, ComparisionSnapshot.Directories[w])); } - DiffViewTreeView.Nodes.Add(node); + } + else + { + var compareRoot = ComparisionSnapshot.Directories.Single(x => x.Value.IsRootFolder).Value; + + renames.AddRange(ActiveSnapshot.FindFileRenames(folder, compareRoot)); } } + + foreach (var rename in renames) + { + DiffViewTreeView.Nodes.Add($"From: {rename.From.Name}"); + DiffViewTreeView.Nodes.Add($"To: {rename.To.Name}"); + } + var dupCount = 0; + + //foreach(var folder in ActiveSnapshot.TopLevelFolders.Keys) + //{ + // foreach(var dup in ActiveSnapshot.FindDuplicates(ActiveSnapshot.Directories[folder])) + // { + // var node = new TreeNode($"{dup.File.Name} ({dup.Duplicates.Count})") { ToolTipText = dup.File.FullPath }; + // foreach(var d in dup.Duplicates) + // { + // node.Nodes.Add(new TreeNode(d.Name) { ToolTipText = d.FullPath }); + // dupCount++; + // } + // DiffViewTreeView.Nodes.Add(node); + // } + //} UpdateStatusLabel($"Found {dupCount} duplicate files."); //foreach(var file in diff.NewFiles) // AddFileSnapshotToDiffView(file, GetSelectedFolderGroup(), FileSnapshot.FileStatus.PendingInsert); diff --git a/DataOrganizer/FileManager.resx b/DataOrganizer/FileManager.resx index 0e5bf2c..57b87f9 100644 --- a/DataOrganizer/FileManager.resx +++ b/DataOrganizer/FileManager.resx @@ -123,4 +123,10 @@ 205, 17 + + 17, 17 + + + 205, 17 + \ No newline at end of file diff --git a/DataOrganizer/Snapshot.cs b/DataOrganizer/Snapshot.cs index c3d2ae9..236c778 100644 --- a/DataOrganizer/Snapshot.cs +++ b/DataOrganizer/Snapshot.cs @@ -265,7 +265,10 @@ namespace DataOrganizer foreach(var f in b.Files.Values) { if (file.Size == f.Size && file.CreatedDate == f.CreatedDate && file.ModifiedDate == f.ModifiedDate) - renames.Add(new SnapshotComparsion.RenamedFile() { From = file, To = f }); + { + if(f.Name != file.Name) + renames.Add(new SnapshotComparsion.RenamedFile() { From = file, To = f }); + } } }