Horizon – Diff between revs 8 and 11

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 8 Rev 11
Line 239... Line 239...
239   239  
240 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) 240 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i)
241 { 241 {
242 try 242 try
243 { 243 {
244 var fileStream = await _snapshotDatabase.RetrieveFileStream( 244 var fileStream = await _snapshotDatabase.RetrieveFileStreamAsync(
245 (string)rows[i].Cells["HashColumn"].Value, 245 (string)rows[i].Cells["HashColumn"].Value,
Line 246... Line 246...
246 cancellationToken); 246 cancellationToken);
247   247  
Line 292... Line 292...
292 } 292 }
Line 293... Line 293...
293   293  
Line 294... Line 294...
294 var hash = (string)row.Cells["HashColumn"].Value; 294 var hash = (string)row.Cells["HashColumn"].Value;
295   295  
296 var snapshotPreview = 296 var snapshotPreview =
Line 297... Line 297...
297 await Task.Run(async () => await _snapshotDatabase.RetrievePreview(hash, _cancellationToken), 297 await Task.Run(async () => await _snapshotDatabase.RetrievePreviewAsync(hash, _cancellationToken),
298 _cancellationToken); 298 _cancellationToken);
299   299  
Line 587... Line 587...
587 } 587 }
Line 588... Line 588...
588   588  
589 private async void SnapshotManagerForm_Load(object sender, EventArgs e) 589 private async void SnapshotManagerForm_Load(object sender, EventArgs e)
590 { 590 {
591 toolStripProgressBar1.Minimum = 0; 591 toolStripProgressBar1.Minimum = 0;
Line 592... Line 592...
592 toolStripProgressBar1.Maximum = (int)await _snapshotDatabase.CountSnapshots(_cancellationToken); 592 toolStripProgressBar1.Maximum = (int)await _snapshotDatabase.CountSnapshotsAsync(_cancellationToken);
Line 593... Line 593...
593   593  
594 var snapshotQueue = new ConcurrentQueue<Snapshot>(); 594 var snapshotQueue = new ConcurrentQueue<Snapshot>();
Line 630... Line 630...
630 } 630 }
631 } 631 }
Line 632... Line 632...
632 632
633 try 633 try
634 { 634 {
635 await foreach (var snapshot in _snapshotDatabase.LoadSnapshots(_cancellationToken).WithCancellation(_cancellationToken)) 635 await foreach (var snapshot in _snapshotDatabase.LoadSnapshotsAsync(_cancellationToken).WithCancellation(_cancellationToken))
636 { 636 {
637 snapshotQueue.Enqueue(snapshot); 637 snapshotQueue.Enqueue(snapshot);
Line 638... Line 638...
638 } 638 }
Line 693... Line 693...
693 var name = Path.GetFileName(directoryFile); 693 var name = Path.GetFileName(directoryFile);
694 var path = Path.Combine(Path.GetDirectoryName(directoryFile), name); 694 var path = Path.Combine(Path.GetDirectoryName(directoryFile), name);
Line 695... Line 695...
695   695  
696 try 696 try
697 { 697 {
698 await _snapshotDatabase.CreateSnapshot(name, path, screenCapture, color, 698 await _snapshotDatabase.CreateSnapshotAsync(name, path, screenCapture, color,
Line 699... Line 699...
699 _cancellationToken); 699 _cancellationToken);
700   700  
701 progress.Report(new CreateSnapshotProgressSuccess(file)); 701 progress.Report(new CreateSnapshotProgressSuccess(file));
Line 712... Line 712...
712 var fileName = Path.GetFileName(file); 712 var fileName = Path.GetFileName(file);
713 var pathName = Path.Combine(Path.GetDirectoryName(file), fileName); 713 var pathName = Path.Combine(Path.GetDirectoryName(file), fileName);
Line 714... Line 714...
714   714  
715 try 715 try
716 { 716 {
717 await _snapshotDatabase.CreateSnapshot(fileName, pathName, screenCapture, color, 717 await _snapshotDatabase.CreateSnapshotAsync(fileName, pathName, screenCapture, color,
Line 718... Line 718...
718 _cancellationToken); 718 _cancellationToken);
719   719  
720 progress.Report(new CreateSnapshotProgressSuccess(file)); 720 progress.Report(new CreateSnapshotProgressSuccess(file));
Line 761... Line 761...
761   761  
762 toolStripProgressBar1.Increment(1); 762 toolStripProgressBar1.Increment(1);
763 statusStrip1.Update(); 763 statusStrip1.Update();
Line 764... Line 764...
764 }); 764 });
765   765  
766 await Task.Factory.StartNew(async () => 766 await Task.Factory.StartNew( () =>
767 { 767 {
768 CreateSnapshots(files, screenCapture, _mainForm.TrackedFolders, progress, _cancellationToken); 768 CreateSnapshots(files, screenCapture, _mainForm.TrackedFolders, progress, _cancellationToken);
Line 786... Line 786...
786 color = folder.Color; 786 color = folder.Color;
787 } 787 }
Line 788... Line 788...
788   788  
789 try 789 try
790 { 790 {
791 await _snapshotDatabase.CreateSnapshot(fileName, pathName, screenCapture, color, 791 await _snapshotDatabase.CreateSnapshotAsync(fileName, pathName, screenCapture, color,
792 _cancellationToken); 792 _cancellationToken);
793 } 793 }
794 catch (SQLiteException exception) 794 catch (SQLiteException exception)
795 { 795 {
Line 823... Line 823...
823 color = folder.Color; 823 color = folder.Color;
824 } 824 }
Line 825... Line 825...
825   825  
826 try 826 try
827 { 827 {
828 await _snapshotDatabase.CreateSnapshot(name, path, screenCapture, color, _cancellationToken); 828 await _snapshotDatabase.CreateSnapshotAsync(name, path, screenCapture, color, _cancellationToken);
829 } 829 }
830 catch (SQLiteException exception) 830 catch (SQLiteException exception)
831 { 831 {
832 if (exception.ResultCode == SQLiteErrorCode.Constraint) 832 if (exception.ResultCode == SQLiteErrorCode.Constraint)
Line 917... Line 917...
917 return; 917 return;
918 } 918 }
Line 919... Line 919...
919   919  
920 try 920 try
921 { 921 {
922 var snapshotPreview = await _snapshotDatabase.RetrievePreview( 922 var snapshotPreview = await _snapshotDatabase.RetrievePreviewAsync(
Line 923... Line 923...
923 (string)row.Cells["HashColumn"].Value, _cancellationToken); 923 (string)row.Cells["HashColumn"].Value, _cancellationToken);
924   924  
925 if (snapshotPreview == null) 925 if (snapshotPreview == null)
Line 1000... Line 1000...
1000 return; 1000 return;
1001 } 1001 }
Line 1002... Line 1002...
1002   1002  
Line 1003... Line 1003...
1003 var hash = (string)row.Cells["HashColumn"].Value; 1003 var hash = (string)row.Cells["HashColumn"].Value;
1004   1004  
1005 using (var memoryStream = await _snapshotDatabase.RetrieveFileStream(hash, _cancellationToken)) 1005 using (var memoryStream = await _snapshotDatabase.RetrieveFileStreamAsync(hash, _cancellationToken))
1006 { 1006 {
1007 if (memoryStream == null) 1007 if (memoryStream == null)
1008 { 1008 {
Line 1025... Line 1025...
1025 } 1025 }
1026 } 1026 }
Line 1027... Line 1027...
1027   1027  
1028 private async void HexViewForm_SaveData(object sender, SaveDataEventArgs e) 1028 private async void HexViewForm_SaveData(object sender, SaveDataEventArgs e)
1029 { 1029 {
Line 1030... Line 1030...
1030 var hash = await _snapshotDatabase.UpdateFile(e.Hash, e.Data, _cancellationToken); 1030 var hash = await _snapshotDatabase.UpdateFileAsync(e.Hash, e.Data, _cancellationToken);
1031   1031  
1032 if (string.IsNullOrEmpty(hash)) 1032 if (string.IsNullOrEmpty(hash))
1033 { 1033 {
Line 1315... Line 1315...
1315   1315  
1316 for (var index = 0; index < count && !cancellationToken.IsCancellationRequested; ++index) 1316 for (var index = 0; index < count && !cancellationToken.IsCancellationRequested; ++index)
1317 { 1317 {
1318 try 1318 try
1319 { 1319 {
1320 await _snapshotDatabase.RemoveFile((string)rows[index].Cells["HashColumn"].Value, 1320 await _snapshotDatabase.RemoveFileAsync((string)rows[index].Cells["HashColumn"].Value,
Line 1321... Line 1321...
1321 cancellationToken); 1321 cancellationToken);
1322   1322  
1323 progress.Report(new DataGridViewRowProgressSuccess(rows[index], index)); 1323 progress.Report(new DataGridViewRowProgressSuccess(rows[index], index));
Line 1331... Line 1331...
1331   1331  
1332 private async Task DeleteFilesFast(IReadOnlyList<DataGridViewRow> rows, CancellationToken cancellationToken) 1332 private async Task DeleteFilesFast(IReadOnlyList<DataGridViewRow> rows, CancellationToken cancellationToken)
1333 { 1333 {
Line 1334... Line 1334...
1334 var hashes = rows.Select(row => (string)row.Cells["HashColumn"].Value); 1334 var hashes = rows.Select(row => (string)row.Cells["HashColumn"].Value);
1335   1335  
Line 1336... Line 1336...
1336 await _snapshotDatabase.RemoveFileFast(hashes, cancellationToken); 1336 await _snapshotDatabase.RemoveFileFastAsync(hashes, cancellationToken);
1337 } 1337 }
1338   1338  
Line 1343... Line 1343...
1343   1343  
1344 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) 1344 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i)
1345 { 1345 {
1346 try 1346 try
1347 { 1347 {
1348 await _snapshotDatabase.UpdateNote((string)rows[i].Cells["HashColumn"].Value, note, 1348 await _snapshotDatabase.UpdateNoteAsync((string)rows[i].Cells["HashColumn"].Value, note,
Line 1349... Line 1349...
1349 cancellationToken); 1349 cancellationToken);
1350   1350  
1351 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); 1351 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
Line 1375... Line 1375...
1375   1375  
1376 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) 1376 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i)
1377 { 1377 {
1378 try 1378 try
1379 { 1379 {
1380 await _snapshotDatabase.RemoveColor((string)rows[i].Cells["HashColumn"].Value, 1380 await _snapshotDatabase.RemoveColorAsync((string)rows[i].Cells["HashColumn"].Value,
Line 1381... Line 1381...
1381 cancellationToken); 1381 cancellationToken);
1382   1382  
1383 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); 1383 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
Line 1396... Line 1396...
1396   1396  
1397 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) 1397 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i)
1398 { 1398 {
1399 try 1399 try
1400 { 1400 {
1401 await _snapshotDatabase.UpdateColor((string)rows[i].Cells["HashColumn"].Value, color, 1401 await _snapshotDatabase.UpdateColorAsync((string)rows[i].Cells["HashColumn"].Value, color,
Line 1402... Line 1402...
1402 cancellationToken); 1402 cancellationToken);
1403   1403  
1404 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); 1404 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
Line 1417... Line 1417...
1417   1417  
1418 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) 1418 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i)
1419 { 1419 {
1420 try 1420 try
1421 { 1421 {
1422 await _snapshotDatabase.RevertFile((string)rows[i].Cells["NameColumn"].Value, 1422 await _snapshotDatabase.RevertFileAsync((string)rows[i].Cells["NameColumn"].Value,
1423 (string)rows[i].Cells["HashColumn"].Value, 1423 (string)rows[i].Cells["HashColumn"].Value,
Line 1424... Line 1424...
1424 cancellationToken, _mainForm.Configuration.AtomicOperations); 1424 cancellationToken, _mainForm.Configuration.AtomicOperations);
1425   1425  
Line 1443... Line 1443...
1443 { 1443 {
1444 var fileInfo = new FileInfo((string)rows[i].Cells["NameColumn"].Value); 1444 var fileInfo = new FileInfo((string)rows[i].Cells["NameColumn"].Value);
1445 var file = fileInfo.Name; 1445 var file = fileInfo.Name;
1446 var path = Path.Combine(directory, file); 1446 var path = Path.Combine(directory, file);
Line 1447... Line 1447...
1447   1447  
1448 await _snapshotDatabase.SaveFile(path, (string)rows[i].Cells["HashColumn"].Value, 1448 await _snapshotDatabase.SaveFileAsync(path, (string)rows[i].Cells["HashColumn"].Value,
Line 1449... Line 1449...
1449 cancellationToken); 1449 cancellationToken);
1450   1450  
1451 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); 1451 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
Line 1467... Line 1467...
1467 { 1467 {
1468 try 1468 try
1469 { 1469 {
1470 var path = Path.Combine(directory, (string)rows[i].Cells["NameColumn"].Value); 1470 var path = Path.Combine(directory, (string)rows[i].Cells["NameColumn"].Value);
Line 1471... Line 1471...
1471   1471  
1472 await _snapshotDatabase.RelocateFile((string)rows[i].Cells["HashColumn"].Value, path, 1472 await _snapshotDatabase.RelocateFileAsync((string)rows[i].Cells["HashColumn"].Value, path,
Line 1473... Line 1473...
1473 cancellationToken); 1473 cancellationToken);
1474   1474  
1475 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); 1475 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
Line 1490... Line 1490...
1490 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) 1490 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i)
1491 { 1491 {
1492 try 1492 try
1493 { 1493 {
1494 using (var memoryStream = 1494 using (var memoryStream =
1495 await _snapshotDatabase.RetrieveFileStream((string)rows[i].Cells["HashColumn"].Value, 1495 await _snapshotDatabase.RetrieveFileStreamAsync((string)rows[i].Cells["HashColumn"].Value,
1496 cancellationToken)) 1496 cancellationToken))
1497 { 1497 {
1498 if (memoryStream == null) 1498 if (memoryStream == null)
1499 { 1499 {
1500 continue; 1500 continue;
Line 1504... Line 1504...
1504 { 1504 {
1505 var recomputedHash = md5.ComputeHash(memoryStream); 1505 var recomputedHash = md5.ComputeHash(memoryStream);
1506 var hashHex = BitConverter.ToString(recomputedHash).Replace("-", "") 1506 var hashHex = BitConverter.ToString(recomputedHash).Replace("-", "")
1507 .ToLowerInvariant(); 1507 .ToLowerInvariant();
Line 1508... Line 1508...
1508   1508  
1509 await _snapshotDatabase.UpdateHash((string)rows[i].Cells["HashColumn"].Value, hashHex, 1509 await _snapshotDatabase.UpdateHashAsync((string)rows[i].Cells["HashColumn"].Value, hashHex,
Line 1510... Line 1510...
1510 cancellationToken); 1510 cancellationToken);
Line 1511... Line 1511...
1511   1511  
Line 1551... Line 1551...
1551 var rootPath = new DirectoryInfo(basePath).Name; 1551 var rootPath = new DirectoryInfo(basePath).Name;
1552 var relPath = rowPath.Remove(0, basePath.Length).Trim('\\'); 1552 var relPath = rowPath.Remove(0, basePath.Length).Trim('\\');
1553 var newPath = Path.Combine(targetPath, rootPath, relPath); 1553 var newPath = Path.Combine(targetPath, rootPath, relPath);
Line 1554... Line 1554...
1554   1554  
1555 var hash = (string)rows[i].Cells["HashColumn"].Value; 1555 var hash = (string)rows[i].Cells["HashColumn"].Value;
Line 1556... Line 1556...
1556 await _snapshotDatabase.SaveFile(newPath, hash, cancellationToken); 1556 await _snapshotDatabase.SaveFileAsync(newPath, hash, cancellationToken);
Line 1557... Line 1557...
1557   1557  
1558 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); 1558 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
Line 1577... Line 1577...
1577   1577  
1578 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) 1578 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i)
1579 { 1579 {
1580 try 1580 try
1581 { 1581 {
1582 await _snapshotDatabase.NormalizeTime((string)rows[i].Cells["HashColumn"].Value, 1582 await _snapshotDatabase.NormalizeTimeAsync((string)rows[i].Cells["HashColumn"].Value,
Line 1583... Line 1583...
1583 cancellationToken); 1583 cancellationToken);
1584   1584  
1585 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); 1585 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));
Line 1641... Line 1641...
1641   1641  
1642 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i) 1642 for (var i = 0; i < count && !cancellationToken.IsCancellationRequested; ++i)
1643 { 1643 {
1644 try 1644 try
1645 { 1645 {
1646 await _snapshotDatabase.DeleteScreenshot((string)rows[i].Cells["HashColumn"].Value, 1646 await _snapshotDatabase.DeleteScreenshotAsync((string)rows[i].Cells["HashColumn"].Value,
Line 1647... Line 1647...
1647 cancellationToken); 1647 cancellationToken);
1648   1648  
1649 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i)); 1649 progress.Report(new DataGridViewRowProgressSuccess(rows[i], i));