diff --git a/Duplicati/Library/Utility/WorkerThread.cs b/Duplicati/Library/Utility/WorkerThread.cs
index 850ced0d9..ee4bd9b2e 100644
--- a/Duplicati/Library/Utility/WorkerThread.cs
+++ b/Duplicati/Library/Utility/WorkerThread.cs
@@ -162,6 +162,40 @@ namespace Duplicati.Library.Utility
WorkQueueChanged(this);
}
+ ///
+ /// An overloaded AddTask method that allows a task to skip to the front of a queue
+ /// It does this by creating a new queue, adding the new task first, and then adding
+ /// all the old tasks to the new queue. It's cleaner to use a linked list,
+ /// but the performance difference is negligible on such a small queue.
+ ///
+ /// Task.
+ /// If set to true skip queue.
+ public void AddTask(Tx task, bool skipQueue)
+ {
+ if (!skipQueue) {
+ // Fall back to default AddTask method
+ AddTask(task);
+ return;
+ }
+
+ lock (m_lock)
+ {
+ Queue newQueue = new Queue();
+ newQueue.Enqueue(task);
+ while (m_tasks.Count > 0)
+ {
+ Tx n = m_tasks.Dequeue();
+ newQueue.Enqueue(n);
+ }
+ m_tasks = newQueue;
+ m_event.Set();
+ }
+
+ if (WorkQueueChanged != null)
+ WorkQueueChanged(this);
+ }
+
+
///
/// Removes a task from the queue, does not remove the task if it is currently running
///
diff --git a/Duplicati/Server/WebServer/RESTMethods/Backup.cs b/Duplicati/Server/WebServer/RESTMethods/Backup.cs
index 9015c7753..485cba0f8 100644
--- a/Duplicati/Server/WebServer/RESTMethods/Backup.cs
+++ b/Duplicati/Server/WebServer/RESTMethods/Backup.cs
@@ -293,7 +293,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
}
else
{
- Program.WorkThread.AddTask(Runner.CreateTask(DuplicatiOperation.Backup, backup));
+ Program.WorkThread.AddTask(Runner.CreateTask(DuplicatiOperation.Backup, backup), true);
Program.StatusEventNotifyer.SignalNewEvent();
}