From bd02336c5000b400a3b6af400679cc13b7028bbb Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Mon, 6 May 2013 20:51:15 +0200 Subject: [PATCH] Changed dblocator to use json instead of xml, as it is a little easier to use. --- .../Library/Main/ForestHash/DatabaseLocator.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Duplicati/Library/Main/ForestHash/DatabaseLocator.cs b/Duplicati/Library/Main/ForestHash/DatabaseLocator.cs index e28ee7b86..ab6a9391b 100644 --- a/Duplicati/Library/Main/ForestHash/DatabaseLocator.cs +++ b/Duplicati/Library/Main/ForestHash/DatabaseLocator.cs @@ -17,8 +17,8 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA using System; using System.Linq; -using System.Xml.Serialization; using System.Collections.Generic; +using Newtonsoft.Json.Serialization; namespace Duplicati.Library.Main.ForestHash { @@ -46,15 +46,12 @@ namespace Duplicati.Library.Main.ForestHash if (!System.IO.Directory.Exists(folder)) System.IO.Directory.CreateDirectory(folder); - var file = System.IO.Path.Combine(folder, "dbconfig.xml"); + var file = System.IO.Path.Combine(folder, "dbconfig.json"); List configs; if (!System.IO.File.Exists(file)) configs = new List(); else - { - using(var fs = System.IO.File.OpenRead(file)) - configs = (List)new System.Xml.Serialization.XmlSerializer(typeof(List)).Deserialize(fs); - } + configs = Newtonsoft.Json.JsonConvert.DeserializeObject>(System.IO.File.ReadAllText(file, System.Text.Encoding.UTF8)); var uri = new Utility.Uri(backend); string server = uri.Host; @@ -139,8 +136,9 @@ namespace Duplicati.Library.Main.ForestHash ParameterFile = null }); - using(var fs = System.IO.File.OpenWrite(file)) - new System.Xml.Serialization.XmlSerializer(typeof(List)).Serialize(fs, configs); + var settings = new Newtonsoft.Json.JsonSerializerSettings(); + settings.Formatting = Newtonsoft.Json.Formatting.Indented; + System.IO.File.WriteAllText(file, Newtonsoft.Json.JsonConvert.SerializeObject(configs, settings), System.Text.Encoding.UTF8); return newpath; }