private async void RunRecoverDirectoryEntryTaskAsync(string path, DatabaseFile databaseFile) { RecoveryTask recoverTask = null; var numFiles = databaseFile.CountFiles(); _taskRunner.Maximum = numFiles; _taskRunner.Interval = 1; await _taskRunner.RunTaskAsync("Save File", (CancellationToken cancellationToken, IProgress <int> progress) => { recoverTask = new RecoveryTask(this._volume, cancellationToken, progress); recoverTask.Save(path, databaseFile); }, (int progress) => { string currentFile = recoverTask.GetCurrentFile(); _taskRunner.UpdateLabel($"{progress}/{numFiles}: {currentFile}"); _taskRunner.UpdateProgress(progress); }, () => { Console.WriteLine("Finished saving files."); }); }
private async void RunRecoverClusterTaskAsync(string path, List <DatabaseFile> dirents) { RecoveryTask recoverTask = null; long numFiles = CountFiles(dirents); _taskRunner.Maximum = numFiles; _taskRunner.Interval = 1; await _taskRunner.RunTaskAsync("Save All", (CancellationToken cancellationToken, IProgress <int> progress) => { try { recoverTask = new RecoveryTask(this._volume, cancellationToken, progress); recoverTask.SaveAll(path, dirents); } catch (OperationCanceledException) { Console.WriteLine("Save all cancelled"); } }, (int progress) => { string currentFile = recoverTask.GetCurrentFile(); _taskRunner.UpdateLabel($"{progress}/{numFiles}: {currentFile}"); _taskRunner.UpdateProgress(progress); }, () => { Console.WriteLine("Finished saving files."); }); }
private async void RunRecoverAllTaskAsync(string path, Dictionary <string, List <DatabaseFile> > clusters) { // TODO: There should be a better way to run this. RecoveryTask recoverTask = null; long numFiles = 0; foreach (var cluster in clusters) { numFiles += CountFiles(cluster.Value); } _taskRunner.Maximum = numFiles; _taskRunner.Interval = 1; await _taskRunner.RunTaskAsync("Save File", (CancellationToken cancellationToken, IProgress <int> progress) => { recoverTask = new RecoveryTask(this._volume, cancellationToken, progress); foreach (var cluster in clusters) { string clusterDir = path + "\\" + cluster.Key; Directory.CreateDirectory(clusterDir); recoverTask.SaveAll(clusterDir, cluster.Value); } }, (int progress) => { string currentFile = recoverTask.GetCurrentFile(); _taskRunner.UpdateLabel($"{progress}/{numFiles}: {currentFile}"); _taskRunner.UpdateProgress(progress); }, () => { Console.WriteLine("Finished saving files."); }); }