Fixed a duplication bug in the Snapshot Merge function.
This commit is contained in:
Binary file not shown.
@@ -171,13 +171,11 @@ namespace DataOrganizer
|
||||
var snapShot = new Snapshot(files, folderGroup);
|
||||
ActiveSnapshotForPrimaryTree.MergeSnapshot(snapShot);
|
||||
|
||||
var newFiles = snapShot.Files.Values.Except(ActiveSnapshotForPrimaryTree.Files.Values);
|
||||
var existingFiles = ActiveSnapshotForPrimaryTree.Files.Values.Except(snapShot.Files.Values);
|
||||
var newFilesCount = 0;
|
||||
var modifiedFilesCount = 0;
|
||||
var deletedFilesCount = 0;
|
||||
|
||||
foreach(var f in newFiles)
|
||||
foreach(var f in ActiveSnapshotForPrimaryTree.Files.Values.Where(x => x.Status == FileSnapshot.FileStatus.PendingInsert))//newFiles)
|
||||
{
|
||||
var newNode = new TreeNode(f.Name) { Name = f.FullPath, BackColor = Color.LightBlue, ToolTipText = "New File Found!" };
|
||||
var folders = ProcessFileFolders(f);
|
||||
|
||||
+16
-13
@@ -167,44 +167,47 @@ 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 newFiles = new List<FileSnapshot>();
|
||||
var existingFiles = Files.Values.Except(snapshot.Files.Values);
|
||||
|
||||
foreach(var file in snapshot.Files)
|
||||
if (!Files.ContainsKey(file.Key)) newFiles.Add(file.Value);
|
||||
|
||||
foreach (var folder in snapshot.OrganizationFolders)
|
||||
{
|
||||
if (!OrganizationFolders.ContainsKey(folder.Key) && folder.Key != Root.FullPath)
|
||||
{
|
||||
Root.AddDirectory(snapshot.Directories[folder.Key]);
|
||||
OrganizationFolders.Add(folder.Key, new List<FileSnapshot>());
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
OrganizationFolders[newFile.OrganizationalFolder.FullPath].Add(newFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user