private PathScanResults <string> DoWork(Models.Backup backup, CancellationToken cancellationToken) { PathScanResults <string> results = new PathScanResults <string>(); BackupedFileRepository daoBackupedFile = new BackupedFileRepository(); // Load pending `BackupedFiles` from `Backup`. IList <Models.BackupedFile> pendingFiles = daoBackupedFile.GetByBackupAndStatus(backup, // 1. We don't want to resume a file that FAILED. // 2. We don't want to resume a file that was CANCELED. // Theoretically, a CANCELED file should never be present in a backup that is still RUNNING, // unless the backup was being CANCELED, and the PlanExecutor was terminated by some reason // after it updated the files as CANCELED but before it got the chance to update the backup // itself as CANCELED. TransferStatus.STOPPED, // The transfer didn't begin. TransferStatus.RUNNING // The transfer did begin but did not complete. ); cancellationToken.ThrowIfCancellationRequested(); // Convert them to a list of paths. results.Files = pendingFiles.ToLinkedList <string, Models.BackupedFile>(p => p.File.Path); return(results); }
// TODO(jweyrich): Should return a HashSet/ISet instead? public override void Scan() { BlockPerfStats stats = new BlockPerfStats(); stats.Begin(); Results = new PathScanResults <CustomVersionedFile>(); // // Add sources. // foreach (var entry in Plan.SelectedSources) { try { switch (entry.Type) { default: throw new InvalidOperationException("Unhandled EntryType"); case EntryType.DRIVE: { AddDirectory(entry); break; } case EntryType.FOLDER: { AddDirectory(entry); break; } case EntryType.FILE: { AddFile(entry); break; } case EntryType.FILE_VERSION: { AddFileVersion(entry); break; } } } catch (OperationCanceledException) { throw; // Rethrow! } catch (Exception ex) { string message = string.Format("Failed to scan entry \"{0}\" - {1}", entry.Path, ex.Message); logger.Log(LogLevel.Error, ex, message); } } stats.End(); }
public override void Scan() { BlockPerfStats stats = new BlockPerfStats(); stats.Begin(); Results = new PathScanResults <string>(); // // Add sources. // foreach (var entry in Plan.SelectedSources) { try { switch (entry.Type) { default: throw new InvalidOperationException("Unhandled EntryType"); case EntryType.DRIVE: { var dir = new ZetaLongPaths.ZlpDirectoryInfo(new DriveInfo(entry.Path).RootDirectory.FullName); AddDirectory(dir); break; } case EntryType.FOLDER: { var dir = new ZetaLongPaths.ZlpDirectoryInfo(entry.Path); AddDirectory(dir); break; } case EntryType.FILE: { var file = new ZetaLongPaths.ZlpFileInfo(entry.Path); AddFile(file); break; } } } catch (OperationCanceledException) { throw; // Rethrow! } catch (Exception ex) { HandleException(entry.Type, entry.Path, ex); } } stats.End(); }