diff --git a/Duplicati/GUI/DuplicatiRunner.cs b/Duplicati/GUI/DuplicatiRunner.cs
index 2f52d6629..e6b66a020 100644
--- a/Duplicati/GUI/DuplicatiRunner.cs
+++ b/Duplicati/GUI/DuplicatiRunner.cs
@@ -54,6 +54,7 @@ namespace Duplicati.GUI
private object m_lock = new object();
private System.Windows.Forms.CloseReason m_stopReason = System.Windows.Forms.CloseReason.None;
private Library.Main.LiveControl.ILiveControl m_currentBackupControlInterface;
+ private bool m_isAborted = false;
public void ExecuteTask(IDuplicityTask task)
{
@@ -66,7 +67,7 @@ namespace Duplicati.GUI
string results = "";
string parsedMessage = "";
- bool isAbortException = false;
+ m_isAborted = false;
try
{
@@ -219,13 +220,13 @@ namespace Duplicati.GUI
if (ex is System.Threading.ThreadAbortException)
{
- isAbortException = true;
+ m_isAborted = true;
System.Threading.Thread.ResetAbort();
}
else if (ex is Library.Main.LiveControl.ExecutionStoppedException)
- isAbortException = true;
+ m_isAborted = true;
- if (isAbortException && m_stopReason != System.Windows.Forms.CloseReason.None)
+ if (m_isAborted && m_stopReason != System.Windows.Forms.CloseReason.None)
{
//If the user has stopped the backup for some reason, write a nicer message
switch (m_stopReason)
@@ -267,7 +268,7 @@ namespace Duplicati.GUI
try
{
- if (!isAbortException && (task.TaskType == DuplicityTaskType.FullBackup || task.TaskType == DuplicityTaskType.IncrementalBackup))
+ if (!m_isAborted && (task.TaskType == DuplicityTaskType.FullBackup || task.TaskType == DuplicityTaskType.IncrementalBackup))
{
if (task.Schedule.Task.KeepFull > 0)
{
@@ -311,10 +312,11 @@ namespace Duplicati.GUI
results += Environment.NewLine + string.Format(Strings.DuplicatiRunner.CleanupError, ex.Message);
}
+ task.IsAborted = m_isAborted;
task.Result = results;
task.RaiseTaskCompleted(results, parsedMessage);
- if (task.Schedule != null && !isAbortException)
+ if (task.Schedule != null && !m_isAborted)
task.Schedule.ScheduledRunCompleted(); //Register as completed if not aborted
}
@@ -359,6 +361,10 @@ namespace Duplicati.GUI
{
ListBackupsTask task = new ListBackupsTask(schedule);
ExecuteTask(task);
+
+ if (task.IsAborted)
+ return null;
+
return task.Backups;
}
@@ -366,8 +372,13 @@ namespace Duplicati.GUI
{
ListBackupEntriesTask task = new ListBackupEntriesTask(schedule);
ExecuteTask(task);
+
+ if (task.IsAborted)
+ return null;
+
if (task.Result.StartsWith("Error:"))
throw new Exception(task.Result);
+
return task.Backups;
}
@@ -375,8 +386,13 @@ namespace Duplicati.GUI
{
ListActualFilesTask task = new ListActualFilesTask(schedule, when);
ExecuteTask(task);
+
+ if (task.IsAborted)
+ return null;
+
if (task.Result.StartsWith("Error:"))
throw new Exception(task.Result);
+
return task.Files;
}
@@ -384,6 +400,10 @@ namespace Duplicati.GUI
{
ListFilesTask task = new ListFilesTask(schedule, when);
ExecuteTask(task);
+
+ if (task.IsAborted)
+ return null;
+
if (task.Result.StartsWith("Error:"))
throw new Exception(task.Result);
return task.Files;
@@ -393,8 +413,13 @@ namespace Duplicati.GUI
{
ListSourceFoldersTask task = new ListSourceFoldersTask(schedule, when);
ExecuteTask(task);
+
+ if (task.IsAborted)
+ return null;
+
if (task.Result.StartsWith("Error:"))
throw new Exception(task.Result);
+
return task.Files;
}
@@ -408,6 +433,11 @@ namespace Duplicati.GUI
PerformBackup(schedule, true, null);
}
+ ///
+ /// Gets a value indicating if the last run was aborted
+ ///
+ public bool IsAborted { get { return m_isAborted; } }
+
///
/// Function used to apply settings to a new interface
///
diff --git a/Duplicati/GUI/HelperControls/BackupFileList.cs b/Duplicati/GUI/HelperControls/BackupFileList.cs
index 1877f9ea1..b01fff898 100644
--- a/Duplicati/GUI/HelperControls/BackupFileList.cs
+++ b/Duplicati/GUI/HelperControls/BackupFileList.cs
@@ -84,7 +84,7 @@ namespace Duplicati.GUI.HelperControls
DuplicatiRunner r = new DuplicatiRunner();
//TODO: Speed up by returning the source folders from ListFiles somehow?
IList sourcefolders = r.ListSourceFolders(m_schedule, m_when);
- if (backgroundWorker.CancellationPending)
+ if (r.IsAborted || backgroundWorker.CancellationPending)
{
e.Cancel = true;
return;
@@ -93,7 +93,7 @@ namespace Duplicati.GUI.HelperControls
if (m_files == null || m_files.Count == 0)
{
IList files = r.ListFiles(m_schedule, m_when);
- if (backgroundWorker.CancellationPending)
+ if (backgroundWorker.CancellationPending || r.IsAborted)
{
e.Cancel = true;
return;
diff --git a/Duplicati/GUI/HelperControls/BackupItems.cs b/Duplicati/GUI/HelperControls/BackupItems.cs
index 494df6b1b..0278eda01 100644
--- a/Duplicati/GUI/HelperControls/BackupItems.cs
+++ b/Duplicati/GUI/HelperControls/BackupItems.cs
@@ -79,6 +79,8 @@ namespace Duplicati.GUI.HelperControls
lock (m_lock)
m_runner = new DuplicatiRunner();
e.Result = m_runner.ListBackupEntries(m_schedule);
+ if (m_runner.IsAborted)
+ e.Cancel = true;
}
finally
{
diff --git a/Duplicati/GUI/ListBackupFiles.Designer.cs b/Duplicati/GUI/ListBackupFiles.Designer.cs
index 7cd72bf3d..b916dd10a 100644
--- a/Duplicati/GUI/ListBackupFiles.Designer.cs
+++ b/Duplicati/GUI/ListBackupFiles.Designer.cs
@@ -82,6 +82,7 @@ namespace Duplicati.GUI
//
// backgroundWorker1
//
+ this.backgroundWorker1.WorkerSupportsCancellation = true;
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
//
diff --git a/Duplicati/GUI/ListBackupFiles.cs b/Duplicati/GUI/ListBackupFiles.cs
index 309aa80a5..ff9b9cf09 100644
--- a/Duplicati/GUI/ListBackupFiles.cs
+++ b/Duplicati/GUI/ListBackupFiles.cs
@@ -75,6 +75,8 @@ namespace Duplicati.GUI
object[] args = (object[])e.Argument;
DuplicatiRunner r = new DuplicatiRunner();
e.Result = r.ListActualFiles((Datamodel.Schedule)args[0], (DateTime)args[1]);
+ if (r.IsAborted)
+ e.Cancel = true;
}
catch (System.Threading.ThreadAbortException)
{
@@ -90,6 +92,10 @@ namespace Duplicati.GUI
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
+ //If the user has closed, ignore any results
+ if (!this.Visible)
+ return;
+
if (e.Cancelled)
this.Close();
else if (e.Error != null || e.Result == null)
diff --git a/Duplicati/GUI/TaskPackages.cs b/Duplicati/GUI/TaskPackages.cs
index 98ea4877c..85d5b8a46 100644
--- a/Duplicati/GUI/TaskPackages.cs
+++ b/Duplicati/GUI/TaskPackages.cs
@@ -57,6 +57,8 @@ namespace Duplicati.GUI
string LocalPath { get; }
string Result { get; set; }
+
+ bool IsAborted { get; set; }
}
public abstract class BackupTask : IDuplicityTask
@@ -65,7 +67,9 @@ namespace Duplicati.GUI
protected DateTime m_beginTime;
protected string m_result;
+ protected bool m_isAborted = false;
+ public bool IsAborted { get { return m_isAborted; } set { m_isAborted = value; } }
public abstract DuplicityTaskType TaskType { get; }
public Schedule Schedule { get { return m_schedule; } }