Started work on a cleaner more focused file manager form. The form will only be used to diff profile group folders, other tasks will be reserved for future forms.

This commit is contained in:
Admin
2020-12-09 19:09:34 -06:00
parent f1a0a5966a
commit 73ede9e367
8 changed files with 669 additions and 2 deletions
+49 -1
View File
@@ -211,6 +211,51 @@ namespace DataOrganizer
}
}
public SnapshotComparsion Diff(Snapshot snapshot)
{
return Compare(this, snapshot);
}
private SnapshotComparsion Compare(Snapshot a, Snapshot b)
{
var newFiles = new List<FileSnapshot>();
var modifiedFiles = new List<FileSnapshot>();
var deletedFiles = new List<FileSnapshot>();
var existingFiles = a.Files.Values.Except(b.Files.Values);
var newOrgFolders = new List<Folder>();
foreach (var file in b.Files)
if (!a.Files.ContainsKey(file.Key)) newFiles.Add(file.Value);
foreach (var folder in b.OrganizationFolders)
{
if (!a.OrganizationFolders.ContainsKey(folder.Key) && folder.Key != a.Root.FullPath)
{
newOrgFolders.Add(b.Directories[folder.Key]);
}
}
foreach (var existingFile in existingFiles)
{
if (!b.Files.ContainsKey(existingFile.FullPath))
{
deletedFiles.Add(existingFile);
}
else if (existingFile.ModifiedDate != b.Files[existingFile.FullPath].ModifiedDate)
{
modifiedFiles.Add(b.Files[existingFile.FullPath]);
}
}
return new SnapshotComparsion()
{
NewFiles = newFiles,
ModifiedFiles = modifiedFiles,
DeletedFiles = deletedFiles,
NewOrganizationalFolders = newOrgFolders
};
}
public struct Duplicate
{
public DB.DBFileSnapshot File;
@@ -394,6 +439,9 @@ namespace DataOrganizer
public class SnapshotComparsion
{
public List<FileSnapshot> NewFiles { get; set; }
public List<FileSnapshot> ModifiedFiles { get; set; }
public List<FileSnapshot> DeletedFiles { get; set; }
public List<Folder> NewOrganizationalFolders { get; set; }
}
}