/Horizon/Snapshots/SnapshotManagerForm.cs |
@@ -676,7 +676,7 @@ |
e.Effect = DragDropEffects.None; |
} |
|
private Task CreateSnapshots(IReadOnlyList<string> files, Bitmap screenCapture, TrackedFolders.TrackedFolders trackedFolders, IProgress<CreateSnapshotProgress> progress, CancellationToken cancellationToken) |
private void CreateSnapshots(IReadOnlyList<string> files, Bitmap screenCapture, TrackedFolders.TrackedFolders trackedFolders, IProgress<CreateSnapshotProgress> progress, CancellationToken cancellationToken) |
{ |
Parallel.ForEach(files, new ParallelOptions { MaxDegreeOfParallelism = 512 }, async file => |
{ |
@@ -766,86 +766,8 @@ |
|
await Task.Factory.StartNew(async () => |
{ |
await CreateSnapshots(files, screenCapture, _mainForm.TrackedFolders, progress, _cancellationToken); |
CreateSnapshots(files, screenCapture, _mainForm.TrackedFolders, progress, _cancellationToken); |
}, _cancellationToken); |
|
/* |
|
foreach (var file in files) |
{ |
var color = Color.Empty; |
if (_mainForm.TrackedFolders.TryGet(file, out var folder)) |
{ |
color = folder.Color; |
} |
|
var fileInfo = File.GetAttributes(file); |
if (fileInfo.HasFlag(FileAttributes.Directory)) |
{ |
foreach (var directoryFile in Directory.GetFiles(file, "*.*", SearchOption.AllDirectories)) |
{ |
var name = Path.GetFileName(directoryFile); |
var path = Path.Combine(Path.GetDirectoryName(directoryFile), name); |
|
try |
{ |
await _snapshotDatabase.CreateSnapshot(name, path, screenCapture, color, |
_cancellationToken); |
|
|
toolStripStatusLabel1.Text = $"Snapshot taken of {file}."; |
toolStripProgressBar1.Increment(1); |
statusStrip1.Update(); |
} |
catch (SQLiteException exception) |
{ |
if (exception.ResultCode == SQLiteErrorCode.Constraint) |
{ |
Log.Information(exception, "Snapshot already exists."); |
|
toolStripStatusLabel1.Text = "Snapshot already exists."; |
toolStripProgressBar1.Increment(1); |
statusStrip1.Update(); |
} |
} |
catch (Exception exception) |
{ |
Log.Warning(exception, "Could not create snapshot."); |
} |
} |
|
continue; |
} |
|
var fileName = Path.GetFileName(file); |
var pathName = Path.Combine(Path.GetDirectoryName(file), fileName); |
|
try |
{ |
await _snapshotDatabase.CreateSnapshot(fileName, pathName, screenCapture, color, |
_cancellationToken); |
|
toolStripStatusLabel1.Text = $"Snapshot taken of {file}."; |
toolStripProgressBar1.Increment(1); |
statusStrip1.Update(); |
} |
catch (SQLiteException exception) |
{ |
if (exception.ResultCode == SQLiteErrorCode.Constraint) |
{ |
Log.Information(exception, "Snapshot already exists."); |
|
toolStripStatusLabel1.Text = "Snapshot already exists."; |
toolStripProgressBar1.Increment(1); |
statusStrip1.Update(); |
} |
} |
catch (Exception exception) |
{ |
Log.Warning(exception, "Could not create snapshot"); |
} |
} |
*/ |
} |
|
private async void FileToolStripMenuItem_Click(object sender, EventArgs e) |