Patched the rename detection function and had some debug output placed in the FileManager form.

This commit is contained in:
Admin
2020-12-16 15:34:42 -06:00
parent 95766b044f
commit d554a31051
5 changed files with 45 additions and 23 deletions
Binary file not shown.
+1
View File
@@ -379,6 +379,7 @@
this.ClientSize = new System.Drawing.Size(1306, 964); this.ClientSize = new System.Drawing.Size(1306, 964);
this.Controls.Add(this.MainLayoutPanel); this.Controls.Add(this.MainLayoutPanel);
this.Name = "FileManager"; this.Name = "FileManager";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "File Manager"; this.Text = "File Manager";
this.MainLayoutPanel.ResumeLayout(false); this.MainLayoutPanel.ResumeLayout(false);
this.MainLayoutPanel.PerformLayout(); this.MainLayoutPanel.PerformLayout();
+37 -25
View File
@@ -81,34 +81,46 @@ namespace DataOrganizer
ComparisionSnapshot = new Snapshot(db.GetFilesForProfileByFolderGroup(p.Id, f.Id), f); ComparisionSnapshot = new Snapshot(db.GetFilesForProfileByFolderGroup(p.Id, f.Id), f);
var diff = ActiveSnapshot.Diff(ComparisionSnapshot); var diff = ActiveSnapshot.Diff(ComparisionSnapshot);
//foreach (var folder in ActiveSnapshot.Directories.Values) foreach (var folder in ActiveSnapshot.Directories.Values)
//{ {
// if (ComparisionSnapshot.Directories.ContainsKey(folder.FullPath)) if (!folder.IsRootFolder)
// { {
// renames.AddRange(ActiveSnapshot.FindFileRenames(folder, ComparisionSnapshot.Directories[folder.FullPath])); var noRoot = folder.FullPath.Remove(0, ActiveSnapshot.Root.FullPath.Length + 1);
// } var w = Path.Combine(f.Path, noRoot);
//}
//foreach (var rename in renames) if (ComparisionSnapshot.Directories.ContainsKey(w))
//{ {
// DiffViewTreeView.Nodes.Add($"From: {rename.From.Name}"); renames.AddRange(ActiveSnapshot.FindFileRenames(folder, ComparisionSnapshot.Directories[w]));
// DiffViewTreeView.Nodes.Add($"To: {rename.To.Name}"); }
//} }
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; var dupCount = 0;
foreach(var folder in ActiveSnapshot.TopLevelFolders.Keys) //foreach(var folder in ActiveSnapshot.TopLevelFolders.Keys)
{ //{
foreach(var dup in ActiveSnapshot.FindDuplicates(ActiveSnapshot.Directories[folder])) // foreach(var dup in ActiveSnapshot.FindDuplicates(ActiveSnapshot.Directories[folder]))
{ // {
var node = new TreeNode($"{dup.File.Name} ({dup.Duplicates.Count})") { ToolTipText = dup.File.FullPath }; // var node = new TreeNode($"{dup.File.Name} ({dup.Duplicates.Count})") { ToolTipText = dup.File.FullPath };
foreach(var d in dup.Duplicates) // foreach(var d in dup.Duplicates)
{ // {
node.Nodes.Add(new TreeNode(d.Name) { ToolTipText = d.FullPath }); // node.Nodes.Add(new TreeNode(d.Name) { ToolTipText = d.FullPath });
dupCount++; // dupCount++;
} // }
DiffViewTreeView.Nodes.Add(node); // DiffViewTreeView.Nodes.Add(node);
} // }
} //}
UpdateStatusLabel($"Found {dupCount} duplicate files."); UpdateStatusLabel($"Found {dupCount} duplicate files.");
//foreach(var file in diff.NewFiles) //foreach(var file in diff.NewFiles)
// AddFileSnapshotToDiffView(file, GetSelectedFolderGroup(), FileSnapshot.FileStatus.PendingInsert); // AddFileSnapshotToDiffView(file, GetSelectedFolderGroup(), FileSnapshot.FileStatus.PendingInsert);
+6
View File
@@ -123,4 +123,10 @@
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>205, 17</value> <value>205, 17</value>
</metadata> </metadata>
<metadata name="MainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>205, 17</value>
</metadata>
</root> </root>
+3
View File
@@ -265,9 +265,12 @@ namespace DataOrganizer
foreach(var f in b.Files.Values) foreach(var f in b.Files.Values)
{ {
if (file.Size == f.Size && file.CreatedDate == f.CreatedDate && file.ModifiedDate == f.ModifiedDate) if (file.Size == f.Size && file.CreatedDate == f.CreatedDate && file.ModifiedDate == f.ModifiedDate)
{
if(f.Name != file.Name)
renames.Add(new SnapshotComparsion.RenamedFile() { From = file, To = f }); renames.Add(new SnapshotComparsion.RenamedFile() { From = file, To = f });
} }
} }
}
return renames; return renames;
} }