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.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();
+34 -22
View File
@@ -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);
+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">
<value>205, 17</value>
</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>
+4 -1
View File
@@ -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 });
}
}
}