Horizon – Diff between revs 6 and 7
?pathlinks?
Rev 6 | Rev 7 | |||
---|---|---|---|---|
Line 674... | Line 674... | |||
674 | } |
674 | } |
|
Line 675... | Line 675... | |||
675 | |
675 | |
|
676 | e.Effect = DragDropEffects.None; |
676 | e.Effect = DragDropEffects.None; |
|
Line 677... | Line 677... | |||
677 | } |
677 | } |
|
678 | |
678 | |
|
679 | private Task CreateSnapshots(IReadOnlyList<string> files, Bitmap screenCapture, TrackedFolders.TrackedFolders trackedFolders, IProgress<CreateSnapshotProgress> progress, CancellationToken cancellationToken) |
679 | private void CreateSnapshots(IReadOnlyList<string> files, Bitmap screenCapture, TrackedFolders.TrackedFolders trackedFolders, IProgress<CreateSnapshotProgress> progress, CancellationToken cancellationToken) |
|
680 | { |
680 | { |
|
681 | Parallel.ForEach(files, new ParallelOptions { MaxDegreeOfParallelism = 512 }, async file => |
681 | Parallel.ForEach(files, new ParallelOptions { MaxDegreeOfParallelism = 512 }, async file => |
|
682 | { |
682 | { |
|
Line 764... | Line 764... | |||
764 | statusStrip1.Update(); |
764 | statusStrip1.Update(); |
|
765 | }); |
765 | }); |
|
Line 766... | Line 766... | |||
766 | |
766 | |
|
767 | await Task.Factory.StartNew(async () => |
767 | await Task.Factory.StartNew(async () => |
|
768 | { |
768 | { |
|
769 | await CreateSnapshots(files, screenCapture, _mainForm.TrackedFolders, progress, _cancellationToken); |
769 | CreateSnapshots(files, screenCapture, _mainForm.TrackedFolders, progress, _cancellationToken); |
|
770 | }, _cancellationToken); |
- | ||
771 | |
- | ||
772 | /* |
- | ||
773 | |
- | ||
774 | foreach (var file in files) |
- | ||
775 | { |
- | ||
776 | var color = Color.Empty; |
- | ||
777 | if (_mainForm.TrackedFolders.TryGet(file, out var folder)) |
- | ||
778 | { |
- | ||
779 | color = folder.Color; |
- | ||
780 | } |
- | ||
781 | |
- | ||
782 | var fileInfo = File.GetAttributes(file); |
- | ||
783 | if (fileInfo.HasFlag(FileAttributes.Directory)) |
- | ||
784 | { |
- | ||
785 | foreach (var directoryFile in Directory.GetFiles(file, "*.*", SearchOption.AllDirectories)) |
- | ||
786 | { |
- | ||
787 | var name = Path.GetFileName(directoryFile); |
- | ||
788 | var path = Path.Combine(Path.GetDirectoryName(directoryFile), name); |
- | ||
789 | |
- | ||
790 | try |
- | ||
791 | { |
- | ||
792 | await _snapshotDatabase.CreateSnapshot(name, path, screenCapture, color, |
- | ||
793 | _cancellationToken); |
- | ||
794 | |
- | ||
795 | |
- | ||
796 | toolStripStatusLabel1.Text = $"Snapshot taken of {file}."; |
- | ||
797 | toolStripProgressBar1.Increment(1); |
- | ||
798 | statusStrip1.Update(); |
- | ||
799 | } |
- | ||
800 | catch (SQLiteException exception) |
- | ||
801 | { |
- | ||
802 | if (exception.ResultCode == SQLiteErrorCode.Constraint) |
- | ||
803 | { |
- | ||
804 | Log.Information(exception, "Snapshot already exists."); |
- | ||
805 | |
- | ||
806 | toolStripStatusLabel1.Text = "Snapshot already exists."; |
- | ||
807 | toolStripProgressBar1.Increment(1); |
- | ||
808 | statusStrip1.Update(); |
- | ||
809 | } |
- | ||
810 | } |
- | ||
811 | catch (Exception exception) |
- | ||
812 | { |
- | ||
813 | Log.Warning(exception, "Could not create snapshot."); |
- | ||
814 | } |
- | ||
815 | } |
- | ||
816 | |
- | ||
817 | continue; |
- | ||
818 | } |
- | ||
819 | |
- | ||
820 | var fileName = Path.GetFileName(file); |
- | ||
821 | var pathName = Path.Combine(Path.GetDirectoryName(file), fileName); |
- | ||
822 | |
- | ||
823 | try |
- | ||
824 | { |
- | ||
825 | await _snapshotDatabase.CreateSnapshot(fileName, pathName, screenCapture, color, |
- | ||
826 | _cancellationToken); |
- | ||
827 | |
- | ||
828 | toolStripStatusLabel1.Text = $"Snapshot taken of {file}."; |
- | ||
829 | toolStripProgressBar1.Increment(1); |
- | ||
830 | statusStrip1.Update(); |
- | ||
831 | } |
- | ||
832 | catch (SQLiteException exception) |
- | ||
833 | { |
- | ||
834 | if (exception.ResultCode == SQLiteErrorCode.Constraint) |
- | ||
835 | { |
- | ||
836 | Log.Information(exception, "Snapshot already exists."); |
- | ||
837 | |
- | ||
838 | toolStripStatusLabel1.Text = "Snapshot already exists."; |
- | ||
839 | toolStripProgressBar1.Increment(1); |
- | ||
840 | statusStrip1.Update(); |
- | ||
841 | } |
- | ||
842 | } |
- | ||
843 | catch (Exception exception) |
- | ||
844 | { |
- | ||
845 | Log.Warning(exception, "Could not create snapshot"); |
- | ||
846 | } |
- | ||
847 | } |
- | ||
848 | */ |
770 | }, _cancellationToken); |
|
Line 849... | Line 771... | |||
849 | } |
771 | } |
|
850 | |
772 | |
|
851 | private async void FileToolStripMenuItem_Click(object sender, EventArgs e) |
773 | private async void FileToolStripMenuItem_Click(object sender, EventArgs e) |