[tomboy/xdg-migration2] Implement migration of XML preferences.



commit 8a9653cd65adbe2adcb4aa86e19e31e54334c229
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date:   Sun Aug 23 20:49:26 2009 -0700

    Implement migration of XML preferences.

 Tomboy/XmlPreferencesClient.cs |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/Tomboy/XmlPreferencesClient.cs b/Tomboy/XmlPreferencesClient.cs
index 5f8d67c..d0a09a6 100644
--- a/Tomboy/XmlPreferencesClient.cs
+++ b/Tomboy/XmlPreferencesClient.cs
@@ -19,10 +19,22 @@ namespace Tomboy
 
 		public XmlPreferencesClient ()
 		{
-			fileName = Path.Combine (
-				Services.NativeApplication.ConfDir,
-				"prefs.xml");
+			string confDir = Services.NativeApplication.ConfigurationDirectory;
+			fileName = Path.Combine (confDir, "prefs.xml");
 			prefsDoc = new XmlDocument ();
+
+			// Migration from old location
+			// NOTE: Assumes this class is instantiated before
+			//       NoteManager performs its migration
+			if (!Directory.Exists (Services.NativeApplication.DataDirectory) &&
+			    !File.Exists (fileName) &&
+			    File.Exists (Path.Combine (Services.NativeApplication.PreOneDotZeroNoteDirectory, "prefs.xml"))) {
+				if (!Directory.Exists (confDir))
+					Directory.CreateDirectory (confDir);
+				File.Copy (Path.Combine (Services.NativeApplication.PreOneDotZeroNoteDirectory, "prefs.xml"),
+					   fileName);
+			}
+
 			if (File.Exists (fileName))
 				prefsDoc.Load (fileName);
 			events = new Dictionary<string, NotifyEventHandler> ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]