Ejemplo n.º 1
0
        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);
        }