Added a function to allow a snapshot object to handle dealing with the diff on its own.
This commit is contained in:
@@ -168,6 +168,44 @@ namespace DataOrganizer
|
||||
public void MergeSnapshot(Snapshot snapshot)
|
||||
{
|
||||
//TODO: build this out
|
||||
var newFiles = Files.Values.Except(snapshot.Files.Values);
|
||||
var newFolders = Directories.Values.Except(snapshot.Directories.Values);
|
||||
var newOrgFolders = OrganizationFolders.Values.Except(snapshot.OrganizationFolders.Values);
|
||||
var existingFiles = Files.Values.Except(snapshot.Files.Values);
|
||||
|
||||
foreach (var existingFile in existingFiles)
|
||||
{
|
||||
if (!snapshot.Files.ContainsKey(existingFile.FullPath))
|
||||
{
|
||||
existingFile.Status = FileSnapshot.FileStatus.PendingDelete;
|
||||
//deletedFiles.Add(existingFile);
|
||||
//pendingChanges++;
|
||||
}
|
||||
else if (existingFile.ModifiedDate != snapshot.Files[existingFile.FullPath].ModifiedDate)
|
||||
{
|
||||
existingFile.ModifiedDate = snapshot.Files[existingFile.FullPath].ModifiedDate;
|
||||
//modifiedFiles.Add(snapShot.Files[existingFile.FullPath]);
|
||||
//pendingChanges++;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var newFile in newFiles)
|
||||
{
|
||||
if(!Files.ContainsKey(newFile.FullPath)) Files.Add(newFile.FullPath, newFile);
|
||||
Folder folder = newFile.ParentFolder;
|
||||
|
||||
while(folder != null)
|
||||
{
|
||||
if (!Directories.ContainsKey(folder.FullPath))
|
||||
{
|
||||
Directories.Add(folder.FullPath, folder);
|
||||
}
|
||||
|
||||
if (folder.Parent == null && !OrganizationFolders.ContainsKey(folder.FullPath)) OrganizationFolders.Add(folder.FullPath, folder.Files.Values.ToList());
|
||||
|
||||
folder = folder.Parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct Duplicate
|
||||
@@ -344,6 +382,7 @@ namespace DataOrganizer
|
||||
PendingInsert,
|
||||
PendingUpdate,
|
||||
PendingDelete,
|
||||
Deleted,
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user