Fixed sending some options to the runner

This commit is contained in:
Kenneth Skovhede
2014-03-15 01:03:59 +01:00
parent 63da23f7f9
commit 5259f8733d
2 changed files with 27 additions and 14 deletions
+1 -1
View File
@@ -328,7 +328,7 @@ namespace Duplicati.Server
LiveControl.ThreadPriorityChanged += new EventHandler(LiveControl_ThreadPriorityChanged);
LiveControl.ThrottleSpeedChanged += new EventHandler(LiveControl_ThrottleSpeedChanged);
Program.WorkThread = new Duplicati.Library.Utility.WorkerThread<Tuple<long, Server.Serialization.DuplicatiOperation>>(Runner.Run, LiveControl.State == LiveControls.LiveControlState.Paused);
Program.WorkThread = new Duplicati.Library.Utility.WorkerThread<Tuple<long, Server.Serialization.DuplicatiOperation>>((x) => { Runner.Run(x); }, LiveControl.State == LiveControls.LiveControlState.Paused);
Program.Scheduler = new Scheduler(WorkThread);
Program.WorkThread.StartingWork += new EventHandler(SignalNewEvent);
+26 -13
View File
@@ -182,11 +182,10 @@ namespace Duplicati.Server
return t;
}
public static void Run(Tuple<long, Server.Serialization.DuplicatiOperation> item)
public static Duplicati.Library.Interface.IBasicResults Run(Tuple<long, Server.Serialization.DuplicatiOperation> item, params object[] args)
{
Duplicati.Server.Serialization.Interface.IBackup backup = null;
try
{
backup = Program.DataConnection.GetBackup(item.Item1);
@@ -198,6 +197,17 @@ namespace Duplicati.Server
Program.GenerateProgressState = () => sink.Copy();
Program.StatusEventNotifyer.SignalNewEvent();
if (args != null && args.Length > 0)
{
var arg = (IDictionary<string, string>)args.Where(x => x != null && typeof(IDictionary<string, string>).IsAssignableFrom(x.GetType())).FirstOrDefault();
if (arg != null)
{
args = args.Where(x => x != arg).ToArray();
foreach(var k in arg.Keys)
options[k] = arg[k];
}
}
using(var controller = new Duplicati.Library.Main.Controller(backup.TargetURL, options, sink))
{
switch (item.Item2)
@@ -213,45 +223,47 @@ namespace Duplicati.Server
var r = controller.Backup(sources, filter);
UpdateMetadata(backup, r);
}
break;
return r;
}
case DuplicatiOperation.List:
{
//TODO: Need to pass arguments
var r = controller.List();
string filter = null;
if (args != null && args.Length > 0)
filter = args[0] as string;
var r = controller.List(filter);
UpdateMetadata(backup, r);
return r;
}
break;
case DuplicatiOperation.Repair:
{
var r = controller.Repair();
UpdateMetadata(backup, r);
return r;
}
break;
case DuplicatiOperation.Remove:
{
var r = controller.Delete();
UpdateMetadata(backup, r);
return r;
}
break;
case DuplicatiOperation.Restore:
{
//TODO: Need to pass arguments
var r = controller.Restore(new string[] { "*" });
UpdateMetadata(backup, r);
return r;
}
break;
case DuplicatiOperation.Verify:
{
//TODO: Need to pass arguments
var r = controller.Test();
UpdateMetadata(backup, r);
return r;
}
break;
default:
//TODO: Log this
return;
return null;
}
}
}
@@ -259,6 +271,7 @@ namespace Duplicati.Server
{
Program.DataConnection.LogError(item.Item1, string.Format("Failed while executing \"{0}\" with id: {1}", item.Item2, item.Item1), ex);
//TODO: Update metadata with the error here
return null;
}
}