Update issue #284

Status: Fixed
Removed error message when user cancels the file content listing.
Also fixed a similar error in other places where the operation can be canceled.

git-svn-id: https://duplicati.googlecode.com/svn/trunk@546 59da171f-624f-0410-aa54-27559c288bec
This commit is contained in:
kenneth.skovhede@gmail.com
2010-10-15 16:50:38 +00:00
parent d0f6c3bdec
commit 229f790ea3
6 changed files with 51 additions and 8 deletions
+36 -6
View File
@@ -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);
}
/// <summary>
/// Gets a value indicating if the last run was aborted
/// </summary>
public bool IsAborted { get { return m_isAborted; } }
/// <summary>
/// Function used to apply settings to a new interface
/// </summary>
@@ -84,7 +84,7 @@ namespace Duplicati.GUI.HelperControls
DuplicatiRunner r = new DuplicatiRunner();
//TODO: Speed up by returning the source folders from ListFiles somehow?
IList<string> 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<string> files = r.ListFiles(m_schedule, m_when);
if (backgroundWorker.CancellationPending)
if (backgroundWorker.CancellationPending || r.IsAborted)
{
e.Cancel = true;
return;
@@ -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
{
+1
View File
@@ -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);
//
+6
View File
@@ -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)
+4
View File
@@ -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; } }