Merge pull request #1930 from 4m1g0/fix_restore_remote

Fix restore remote backup, bug introduced in: 6096d8379bca4acb16b52a8…
This commit is contained in:
Kenneth Skovhede
2016-09-12 14:32:41 +02:00
committed by GitHub
@@ -172,16 +172,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
{
var input = info.Request.Form;
string[] filters;
var rawpaths = (input["paths"].Value ?? string.Empty).Trim();
// We send the file list as a JSON array to avoid encoding issues with the path seperator
// as it is an allowed character in file and path names.
// We also accept the old way, for compatibility with the greeno theme
if (!string.IsNullOrWhiteSpace(rawpaths) && rawpaths.StartsWith("[", StringComparison.Ordinal) && rawpaths.EndsWith("]", StringComparison.Ordinal))
filters = Newtonsoft.Json.JsonConvert.DeserializeObject<string[]>(rawpaths);
else
filters = input["paths"].Value.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries);
string[] filters = parsePaths(input["paths"].Value ?? string.Empty);
var time = Duplicati.Library.Utility.Timeparser.ParseTimeInterval(input["time"].Value, DateTime.Now);
var restoreTarget = input["restore-path"].Value;
@@ -234,6 +225,22 @@ namespace Duplicati.Server.WebServer.RESTMethods
info.OutputOK(new { Status = "OK", ID = task.TaskID });
}
private string[] parsePaths(string paths)
{
string[] filters;
var rawpaths = (paths ?? string.Empty).Trim();
// We send the file list as a JSON array to avoid encoding issues with the path seperator
// as it is an allowed character in file and path names.
// We also accept the old way, for compatibility with the greeno theme
if (!string.IsNullOrWhiteSpace(rawpaths) && rawpaths.StartsWith("[", StringComparison.Ordinal) && rawpaths.EndsWith("]", StringComparison.Ordinal))
filters = Newtonsoft.Json.JsonConvert.DeserializeObject<string[]>(rawpaths);
else
filters = paths.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries);
return filters;
}
private void DoRepair(IBackup backup, RequestInfo info, bool repairUpdate)
{
var input = info.Request.Form;
@@ -246,7 +253,7 @@ namespace Duplicati.Server.WebServer.RESTMethods
if (input["version"].Value != null)
extra["version"] = input["version"].Value;
if (input["paths"].Value != null)
filters = input["paths"].Value.Split(new string[] { System.IO.Path.PathSeparator.ToString() }, StringSplitOptions.RemoveEmptyEntries);
filters = parsePaths(input["paths"].Value);
var task = Runner.CreateTask(repairUpdate ? DuplicatiOperation.RepairUpdate : DuplicatiOperation.Repair, backup, extra, filters);
Program.WorkThread.AddTask(task);