From 0bfe3daac4f58a9a95775fa949a38cbd0f19e993 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Wed, 26 Aug 2015 12:38:27 +0100 Subject: [PATCH 1/2] Fixed issues with the REST interface --- Duplicati/Server/Database/Connection.cs | 2 +- Duplicati/Server/WebServer/RESTMethods/Backup.cs | 3 +++ Duplicati/Server/WebServer/RESTMethods/Backups.cs | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Duplicati/Server/Database/Connection.cs b/Duplicati/Server/Database/Connection.cs index 34a28fd5a..86fdf9e56 100644 --- a/Duplicati/Server/Database/Connection.cs +++ b/Duplicati/Server/Database/Connection.cs @@ -408,7 +408,7 @@ namespace Duplicati.Server.Database return new object[] { n.Name, - string.Join(",", n.Tags), + string.Join(",", n.Tags ?? new string[0]), n.TargetURL, update ? (object)item.ID : (object)n.DBPath }; diff --git a/Duplicati/Server/WebServer/RESTMethods/Backup.cs b/Duplicati/Server/WebServer/RESTMethods/Backup.cs index 36130559d..7bf2e37b9 100644 --- a/Duplicati/Server/WebServer/RESTMethods/Backup.cs +++ b/Duplicati/Server/WebServer/RESTMethods/Backup.cs @@ -403,6 +403,9 @@ namespace Duplicati.Server.WebServer.RESTMethods public void PUT(string key, RequestInfo info) { string str = info.Request.Form["data"].Value; + if (string.IsNullOrWhiteSpace(str)) + str = new StreamReader(info.Request.Body, System.Text.Encoding.UTF8).ReadToEnd(); + if (string.IsNullOrWhiteSpace(str)) { info.ReportClientError("Missing backup object"); diff --git a/Duplicati/Server/WebServer/RESTMethods/Backups.cs b/Duplicati/Server/WebServer/RESTMethods/Backups.cs index 33251a881..061cab7cb 100644 --- a/Duplicati/Server/WebServer/RESTMethods/Backups.cs +++ b/Duplicati/Server/WebServer/RESTMethods/Backups.cs @@ -138,7 +138,11 @@ namespace Duplicati.Server.WebServer.RESTMethods AddOrUpdateBackupData data = null; try { - data = Serializer.Deserialize(new StringReader(info.Request.Form["data"].Value)); + var str = info.Request.Form["data"].Value; + if (string.IsNullOrWhiteSpace(str)) + str = new StreamReader(info.Request.Body, System.Text.Encoding.UTF8).ReadToEnd(); + + data = Serializer.Deserialize(new StringReader(str)); if (data.Backup == null) { info.ReportClientError("Data object had no backup entry"); From fec08eb5606ffb9833725ed0077d9baf2ee578bd Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Wed, 26 Aug 2015 12:38:49 +0100 Subject: [PATCH 2/2] Added a sanity check to the repair process --- Duplicati/Library/Main/Operation/RecreateDatabaseHandler.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Duplicati/Library/Main/Operation/RecreateDatabaseHandler.cs b/Duplicati/Library/Main/Operation/RecreateDatabaseHandler.cs index b9d85e191..3d11406a8 100644 --- a/Duplicati/Library/Main/Operation/RecreateDatabaseHandler.cs +++ b/Duplicati/Library/Main/Operation/RecreateDatabaseHandler.cs @@ -129,9 +129,15 @@ namespace Duplicati.Library.Main.Operation orderby n.Time descending select n; + if (filelists.Count() <= 0) + throw new Exception(string.Format("No filelists found on the remote destinatio")); + if (filelistfilter != null) filelists = filelistfilter(filelists).Select(x => x.Value).ToArray(); + if (filelists.Count() <= 0) + throw new Exception(string.Format("No filelists")); + // If we are updating, all files should be accounted for foreach(var fl in remotefiles) volumeIds[fl.File.Name] = updating ? restoredb.GetRemoteVolumeID(fl.File.Name) : restoredb.RegisterRemoteVolume(fl.File.Name, fl.FileType, fl.File.Size, RemoteVolumeState.Uploaded);