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:
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user