/// <summary> /// Releases resources associated with the task /// </summary> public override void Dispose() { base.Dispose(); if (this.backup != null) this.backup.Dispose(); this.backup = null; }
/// <summary> /// Task execution override /// </summary> protected override void DoExecute() { // prepare the backup plugin for the session // and mark it as in-progress this.backup = this.Archive.PrepareBackup(this.Session); if (this.Session.State == SkyFloe.Backup.SessionState.Pending) { this.Session.State = SkyFloe.Backup.SessionState.InProgress; this.Archive.BackupIndex.UpdateSession(this.Session); Checkpoint(); } try { this.limiter = new IO.RateLimiter(this.Session.RateLimit); var checkpointSize = 0L; for (; ; ) { this.Canceler.ThrowIfCancellationRequested(); // fetch the next pending backup entry and // send it to the archive var entry = this.Archive.BackupIndex.LookupNextEntry(this.Session); if (entry == null) break; BackupEntry(entry); // if we have reached the configured checkpoint // size, then force a checkpoint checkpointSize += entry.Length; if (checkpointSize > this.Session.CheckpointLength) { checkpointSize = 0; Checkpoint(); } } // there are no more pending backup entries, so complete the session this.Session.State = SkyFloe.Backup.SessionState.Completed; this.Archive.BackupIndex.UpdateSession(this.Session); Checkpoint(); } catch (OperationCanceledException) { // if the client requested cancellation, attempt to // checkpoint the backup to save our progress Checkpoint(); throw; } }