/Horizon/Database/SnapshotDatabase.cs |
@@ -155,7 +155,7 @@ |
|
#region Public Methods |
|
public async Task DeleteScreenshot(string hash, CancellationToken cancellationToken) |
public async Task DeleteScreenshotAsync(string hash, CancellationToken cancellationToken) |
{ |
var connectionString = new SQLiteConnectionStringBuilder |
{ |
@@ -204,7 +204,7 @@ |
} |
} |
|
public async Task NormalizeTime(string hash, CancellationToken cancellationToken) |
public async Task NormalizeTimeAsync(string hash, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -282,7 +282,7 @@ |
} |
} |
|
public async Task<long> CountSnapshots(CancellationToken cancellationToken) |
public async Task<long> CountSnapshotsAsync(CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -322,7 +322,7 @@ |
} |
} |
|
public async IAsyncEnumerable<Snapshot> LoadSnapshots([EnumeratorCancellation] CancellationToken cancellationToken) |
public async IAsyncEnumerable<Snapshot> LoadSnapshotsAsync([EnumeratorCancellation] CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -376,7 +376,7 @@ |
} |
} |
|
public async Task CreateSnapshot(string name, string path, Color color, CancellationToken cancellationToken) |
public async Task CreateSnapshotAsync(string name, string path, Color color, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -518,7 +518,7 @@ |
} |
} |
|
public async Task CreateSnapshot(string name, string path, |
public async Task CreateSnapshotAsync(string name, string path, |
Bitmap shot, Color color, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
@@ -692,7 +692,7 @@ |
} |
} |
|
public async Task SaveFile(string path, string hash, CancellationToken cancellationToken) |
public async Task SaveFileAsync(string path, string hash, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -750,7 +750,7 @@ |
} |
} |
|
public async Task RevertFile(string name, string hash, CancellationToken cancellationToken, bool atomic = true) |
public async Task RevertFileAsync(string name, string hash, CancellationToken cancellationToken, bool atomic = true) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -870,7 +870,7 @@ |
} |
} |
|
public async Task RemoveFileFast(IEnumerable<string> hashes, CancellationToken cancellationToken) |
public async Task RemoveFileFastAsync(IEnumerable<string> hashes, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -923,7 +923,7 @@ |
} |
} |
|
public async Task RemoveFile(string hash, CancellationToken cancellationToken) |
public async Task RemoveFileAsync(string hash, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -967,7 +967,7 @@ |
} |
} |
|
public async Task UpdateColor(string hash, Color color, CancellationToken cancellationToken) |
public async Task UpdateColorAsync(string hash, Color color, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
|
@@ -1013,7 +1013,7 @@ |
} |
} |
|
public async Task RemoveColor(string hash, CancellationToken cancellationToken) |
public async Task RemoveColorAsync(string hash, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -1057,7 +1057,7 @@ |
} |
} |
|
public async Task<SnapshotPreview> RetrievePreview(string hash, CancellationToken cancellationToken) |
public async Task<SnapshotPreview> RetrievePreviewAsync(string hash, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -1118,7 +1118,7 @@ |
} |
} |
|
public async Task<MemoryStream> RetrieveFileStream(string hash, CancellationToken cancellationToken) |
public async Task<MemoryStream> RetrieveFileStreamAsync(string hash, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -1177,7 +1177,7 @@ |
} |
} |
|
public async Task RelocateFile(string hash, string path, CancellationToken cancellationToken) |
public async Task RelocateFileAsync(string hash, string path, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -1223,7 +1223,7 @@ |
} |
} |
|
public async Task UpdateNote(string hash, string note, CancellationToken cancellationToken) |
public async Task UpdateNoteAsync(string hash, string note, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -1272,7 +1272,7 @@ |
} |
} |
|
public async Task<string> UpdateFile(string hash, byte[] data, CancellationToken cancellationToken) |
public async Task<string> UpdateFileAsync(string hash, byte[] data, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
@@ -1392,7 +1392,7 @@ |
} |
} |
|
public async Task UpdateHash(string from, string to, CancellationToken cancellationToken) |
public async Task UpdateHashAsync(string from, string to, CancellationToken cancellationToken) |
{ |
await _databaseLock.WaitAsync(cancellationToken); |
try |
/Horizon/Snapshots/SnapshotManagerForm.cs |
@@ -241,7 +241,7 @@ |
{ |
try |
{ |
var fileStream = await _snapshotDatabase.RetrieveFileStream( |
var fileStream = await _snapshotDatabase.RetrieveFileStreamAsync( |
(string)rows[i].Cells["HashColumn"].Value, |
cancellationToken); |
|
@@ -294,7 +294,7 @@ |
var hash = (string)row.Cells["HashColumn"].Value; |
|
var snapshotPreview = |
await Task.Run(async () => await _snapshotDatabase.RetrievePreview(hash, _cancellationToken), |
await Task.Run(async () => await _snapshotDatabase.RetrievePreviewAsync(hash, _cancellationToken), |
_cancellationToken); |
|
if (snapshotPreview == null) |
@@ -589,7 +589,7 @@ |
private async void SnapshotManagerForm_Load(object sender, EventArgs e) |
{ |
toolStripProgressBar1.Minimum = 0; |
toolStripProgressBar1.Maximum = (int)await _snapshotDatabase.CountSnapshots(_cancellationToken); |
toolStripProgressBar1.Maximum = (int)await _snapshotDatabase.CountSnapshotsAsync(_cancellationToken); |
|
var snapshotQueue = new ConcurrentQueue<Snapshot>(); |
|
@@ -632,7 +632,7 @@ |
|
try |
{ |
await foreach (var snapshot in _snapshotDatabase.LoadSnapshots(_cancellationToken).WithCancellation(_cancellationToken)) |
await foreach (var snapshot in _snapshotDatabase.LoadSnapshotsAsync(_cancellationToken).WithCancellation(_cancellationToken)) |
{ |
snapshotQueue.Enqueue(snapshot); |
} |
@@ -695,7 +695,7 @@ |
|
try |
{ |
await _snapshotDatabase.CreateSnapshot(name, path, screenCapture, color, |
await _snapshotDatabase.CreateSnapshotAsync(name, path, screenCapture, color, |
_cancellationToken); |
|
progress.Report(new CreateSnapshotProgressSuccess(file)); |
@@ -714,7 +714,7 @@ |
|
try |
{ |
await _snapshotDatabase.CreateSnapshot(fileName, pathName, screenCapture, color, |
await _snapshotDatabase.CreateSnapshotAsync(fileName, pathName, screenCapture, color, |
_cancellationToken); |
|
progress.Report(new CreateSnapshotProgressSuccess(file)); |
@@ -763,7 +763,7 @@ |
statusStrip1.Update(); |
}); |
|
await Task.Factory.StartNew(async () => |
await Task.Factory.StartNew( () => |
{ |
CreateSnapshots(files, screenCapture, _mainForm.TrackedFolders, progress, _cancellationToken); |
}, _cancellationToken); |
@@ -788,7 +788,7 @@ |
|
try |
{ |
await _snapshotDatabase.CreateSnapshot(fileName, pathName, screenCapture, color, |
await _snapshotDatabase.CreateSnapshotAsync(fileName, pathName, screenCapture, color, |
_cancellationToken); |
} |
catch (SQLiteException exception) |
@@ -825,7 +825,7 @@ |
|
try |
{ |
await _snapshotDatabase.CreateSnapshot(name, path, screenCapture, color, _cancellationToken); |
await _snapshotDatabase.CreateSnapshotAsync(name, path, screenCapture, color, _cancellationToken); |
} |
catch (SQLiteException exception) |
{ |
@@ -919,7 +919,7 @@ |
|
try |
{ |
var snapshotPreview = await _snapshotDatabase.RetrievePreview( |
var snapshotPreview = await _snapshotDatabase.RetrievePreviewAsync( |
(string)row.Cells["HashColumn"].Value, _cancellationToken); |
|
if (snapshotPreview == null) |
@@ -1002,7 +1002,7 @@ |
|
var hash = (string)row.Cells["HashColumn"].Value; |
|
using (var memoryStream = await _snapshotDatabase.RetrieveFileStream(hash, _cancellationToken)) |
using (var memoryStream = await _snapshotDatabase.RetrieveFileStreamAsync(hash, _cancellationToken)) |
{ |
if (memoryStream == null) |
{ |
@@ -1027,7 +1027,7 @@ |
|
private async void HexViewForm_SaveData(object sender, SaveDataEventArgs e) |
{ |
var hash = await _snapshotDatabase.UpdateFile(e.Hash, e.Data, _cancellationToken); |
var hash = await _snapshotDatabase.UpdateFileAsync(e.Hash, e.Data, _cancellationToken); |
|
if (string.IsNullOrEmpty(hash)) |
{ |
@@ -1317,7 +1317,7 @@ |
{ |
try |
{ |
await _snapshotDatabase.RemoveFile((string)rows[index].Cells["HashColumn"].Value, |
await _snapshotDatabase.RemoveFileAsync((string)rows[index].Cells["HashColumn"].Value, |
cancellationToken); |
|
progress.Report(new DataGridViewRowProgressSuccess(rows[index], index)); |
@@ -1333,7 +1333,7 @@ |
{ |
var hashes = rows.Select(row => (string)row.Cells["HashColumn"].Value); |
|
await _snapshotDatabase.RemoveFileFast(hashes, cancellationToken); |
await _snapshotDatabase.RemoveFileFastAsync(hashes, cancellationToken); |
} |
|
private async Task UpdateNote(IReadOnlyList<DataGridViewRow> rows, string note, |
@@ -1345,7 +1345,7 @@ |
{ |
try |
{ |
await _snapshotDatabase.UpdateNote((string)rows[i].Cells["HashColumn"].Value, note, |
await _snapshotDatabase.UpdateNoteAsync((string)rows[i].Cells["HashColumn"].Value, note, |
cancellationToken); |
|
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
@@ -1377,7 +1377,7 @@ |
{ |
try |
{ |
await _snapshotDatabase.RemoveColor((string)rows[i].Cells["HashColumn"].Value, |
await _snapshotDatabase.RemoveColorAsync((string)rows[i].Cells["HashColumn"].Value, |
cancellationToken); |
|
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
@@ -1398,7 +1398,7 @@ |
{ |
try |
{ |
await _snapshotDatabase.UpdateColor((string)rows[i].Cells["HashColumn"].Value, color, |
await _snapshotDatabase.UpdateColorAsync((string)rows[i].Cells["HashColumn"].Value, color, |
cancellationToken); |
|
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
@@ -1419,7 +1419,7 @@ |
{ |
try |
{ |
await _snapshotDatabase.RevertFile((string)rows[i].Cells["NameColumn"].Value, |
await _snapshotDatabase.RevertFileAsync((string)rows[i].Cells["NameColumn"].Value, |
(string)rows[i].Cells["HashColumn"].Value, |
cancellationToken, _mainForm.Configuration.AtomicOperations); |
|
@@ -1445,7 +1445,7 @@ |
var file = fileInfo.Name; |
var path = Path.Combine(directory, file); |
|
await _snapshotDatabase.SaveFile(path, (string)rows[i].Cells["HashColumn"].Value, |
await _snapshotDatabase.SaveFileAsync(path, (string)rows[i].Cells["HashColumn"].Value, |
cancellationToken); |
|
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
@@ -1469,7 +1469,7 @@ |
{ |
var path = Path.Combine(directory, (string)rows[i].Cells["NameColumn"].Value); |
|
await _snapshotDatabase.RelocateFile((string)rows[i].Cells["HashColumn"].Value, path, |
await _snapshotDatabase.RelocateFileAsync((string)rows[i].Cells["HashColumn"].Value, path, |
cancellationToken); |
|
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
@@ -1492,7 +1492,7 @@ |
try |
{ |
using (var memoryStream = |
await _snapshotDatabase.RetrieveFileStream((string)rows[i].Cells["HashColumn"].Value, |
await _snapshotDatabase.RetrieveFileStreamAsync((string)rows[i].Cells["HashColumn"].Value, |
cancellationToken)) |
{ |
if (memoryStream == null) |
@@ -1506,7 +1506,7 @@ |
var hashHex = BitConverter.ToString(recomputedHash).Replace("-", "") |
.ToLowerInvariant(); |
|
await _snapshotDatabase.UpdateHash((string)rows[i].Cells["HashColumn"].Value, hashHex, |
await _snapshotDatabase.UpdateHashAsync((string)rows[i].Cells["HashColumn"].Value, hashHex, |
cancellationToken); |
|
rows[i].Cells["HashColumn"].Value = hashHex; |
@@ -1553,7 +1553,7 @@ |
var newPath = Path.Combine(targetPath, rootPath, relPath); |
|
var hash = (string)rows[i].Cells["HashColumn"].Value; |
await _snapshotDatabase.SaveFile(newPath, hash, cancellationToken); |
await _snapshotDatabase.SaveFileAsync(newPath, hash, cancellationToken); |
|
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
|
@@ -1579,7 +1579,7 @@ |
{ |
try |
{ |
await _snapshotDatabase.NormalizeTime((string)rows[i].Cells["HashColumn"].Value, |
await _snapshotDatabase.NormalizeTimeAsync((string)rows[i].Cells["HashColumn"].Value, |
cancellationToken); |
|
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |
@@ -1643,7 +1643,7 @@ |
{ |
try |
{ |
await _snapshotDatabase.DeleteScreenshot((string)rows[i].Cells["HashColumn"].Value, |
await _snapshotDatabase.DeleteScreenshotAsync((string)rows[i].Cells["HashColumn"].Value, |
cancellationToken); |
|
progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); |