Skip to content

Commit

Permalink
Fixed the status so we can run commands with the runner without affec…
Browse files Browse the repository at this point in the history
…ting the status output
  • Loading branch information
kenkendk committed Mar 23, 2014
1 parent 603e32c commit 20f12f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Duplicati/Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public static void Main(string[] args)
LiveControl.ThreadPriorityChanged += new EventHandler(LiveControl_ThreadPriorityChanged);
LiveControl.ThrottleSpeedChanged += new EventHandler(LiveControl_ThrottleSpeedChanged);

Program.WorkThread = new Duplicati.Library.Utility.WorkerThread<Runner.IRunnerData>((x) => { Runner.Run(x); }, LiveControl.State == LiveControls.LiveControlState.Paused);
Program.WorkThread = new Duplicati.Library.Utility.WorkerThread<Runner.IRunnerData>((x) => { Runner.Run(x, true); }, LiveControl.State == LiveControls.LiveControlState.Paused);
Program.Scheduler = new Scheduler(WorkThread);

Program.WorkThread.StartingWork += new EventHandler(SignalNewEvent);
Expand Down
11 changes: 7 additions & 4 deletions Duplicati/Server/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,19 @@ public Duplicati.Library.Main.IOperationProgress OperationProgress
#endregion
}

public static Duplicati.Library.Interface.IBasicResults Run(IRunnerData data, bool throwEx = false)
public static Duplicati.Library.Interface.IBasicResults Run(IRunnerData data, bool fromQueue)
{
Duplicati.Server.Serialization.Interface.IBackup backup = data.Backup;

try
{
var options = ApplyOptions(backup, data.Operation, GetCommonOptions(backup, data.Operation));
var sink = new MessageSink(data.TaskID, backup.ID);
Program.GenerateProgressState = () => sink.Copy();
Program.StatusEventNotifyer.SignalNewEvent();
if (fromQueue)
{
Program.GenerateProgressState = () => sink.Copy();
Program.StatusEventNotifyer.SignalNewEvent();
}

if (data.ExtraOptions != null)
foreach(var k in data.ExtraOptions)
Expand Down Expand Up @@ -308,7 +311,7 @@ public static Duplicati.Library.Interface.IBasicResults Run(IRunnerData data, bo
Program.DataConnection.LogError(data.Backup.ID, string.Format("Failed while executing \"{0}\" with id: {1}", data.Operation, data.Backup.ID), ex);
//TODO: Update metadata with the error here

if (throwEx)
if (!fromQueue)
throw;

return null;
Expand Down
4 changes: 2 additions & 2 deletions Duplicati/Server/WebServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ private void ListBackupSets(HttpServer.IHttpRequest request, HttpServer.IHttpRes
}


var r = Runner.Run(Runner.CreateTask(DuplicatiOperation.List, bk), true) as Duplicati.Library.Interface.IListResults;
var r = Runner.Run(Runner.CreateTask(DuplicatiOperation.List, bk), false) as Duplicati.Library.Interface.IListResults;

OutputObject(bw, r.Filesets);
}
Expand Down Expand Up @@ -463,7 +463,7 @@ private void SearchBackupFiles(HttpServer.IHttpRequest request, HttpServer.IHttp
if (!allversion)
time = Duplicati.Library.Utility.Timeparser.ParseTimeInterval(timestring, DateTime.Now);

var r = Runner.Run(Runner.CreateListTask(bk, filter, prefixonly, allversion, foldercontents, time), true) as Duplicati.Library.Interface.IListResults;
var r = Runner.Run(Runner.CreateListTask(bk, filter, prefixonly, allversion, foldercontents, time), false) as Duplicati.Library.Interface.IListResults;

var result = new Dictionary<string, object>();

Expand Down

0 comments on commit 20f12f6

Please sign in to comment.