Added a function to allow a snapshot object to handle dealing with the diff on its own.
This commit is contained in:
@@ -164,37 +164,19 @@ namespace DataOrganizer
|
||||
var folderGroup = GetActiveFolderGroup();
|
||||
var files = new List<FileInfo>();
|
||||
var rootFolder = new DirectoryInfo(folderGroup.Path);
|
||||
var pendingChanges = 0;
|
||||
|
||||
foreach (var dir in rootFolder.EnumerateDirectories())
|
||||
files.AddRange(ScanDirectory(dir));
|
||||
|
||||
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 deletedFiles = new List<FileSnapshot>();
|
||||
var modifiedFiles = new List<FileSnapshot>();
|
||||
var newFilesCount = 0;
|
||||
var modifiedFilesCount = 0;
|
||||
var deletedFilesCount = 0;
|
||||
|
||||
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 f in newFiles)
|
||||
{
|
||||
var newNode = new TreeNode(f.Name) { Name = f.FullPath, BackColor = Color.LightBlue, ToolTipText = "New File Found!" };
|
||||
@@ -224,17 +206,17 @@ namespace DataOrganizer
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var f in deletedFiles)
|
||||
foreach(var f in ActiveSnapshotForPrimaryTree.Files.Where(x => x.Value.Status == FileSnapshot.FileStatus.PendingDelete))
|
||||
{
|
||||
PrimaryTreeNodes[f.FullPath].BackColor = Color.Red;
|
||||
PrimaryTreeNodes[f.FullPath].ToolTipText = "This file has been deleted.";
|
||||
PrimaryTreeNodes[f.Key].BackColor = Color.Red;
|
||||
PrimaryTreeNodes[f.Key].ToolTipText = "This file has been deleted.";
|
||||
deletedFilesCount++;
|
||||
}
|
||||
|
||||
foreach(var f in modifiedFiles)
|
||||
foreach(var f in ActiveSnapshotForPrimaryTree.Files.Where(x => x.Value.Status == FileSnapshot.FileStatus.PendingUpdate))
|
||||
{
|
||||
PrimaryTreeNodes[f.FullPath].BackColor = Color.DarkBlue;
|
||||
PrimaryTreeNodes[f.FullPath].ToolTipText = "This file has been modified.";
|
||||
PrimaryTreeNodes[f.Key].BackColor = Color.DarkBlue;
|
||||
PrimaryTreeNodes[f.Key].ToolTipText = "This file has been modified.";
|
||||
modifiedFilesCount++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user