From 618015f47e9c35c27f4f24bc23db4bca454aa1f1 Mon Sep 17 00:00:00 2001 From: Panagiotis Kanavos Date: Sun, 19 Feb 2012 19:07:14 +0200 Subject: [PATCH] Moved the pithos.db location to the same location as the user settings. This will make cleanup of all user settings easier during uninstallation --- trunk/Pithos.Core/Agents/StatusAgent.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/trunk/Pithos.Core/Agents/StatusAgent.cs b/trunk/Pithos.Core/Agents/StatusAgent.cs index d5fda6d..5a92d05 100644 --- a/trunk/Pithos.Core/Agents/StatusAgent.cs +++ b/trunk/Pithos.Core/Agents/StatusAgent.cs @@ -31,22 +31,45 @@ namespace Pithos.Core.Agents public StatusAgent() { var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); - _pithosDataPath = Path.Combine(appDataPath , "Pithos"); + + + _pithosDataPath = Path.Combine(appDataPath , "GRNET"); if (!Directory.Exists(_pithosDataPath)) Directory.CreateDirectory(_pithosDataPath); + + var dbPath = Path.Combine(_pithosDataPath, "pithos.db"); + + MigrateOldDb(dbPath, appDataPath); + var source = GetConfiguration(_pithosDataPath); ActiveRecordStarter.Initialize(source,typeof(FileState),typeof(FileTag)); ActiveRecordStarter.UpdateSchema(); - - if (!File.Exists(Path.Combine(_pithosDataPath ,"pithos.db"))) + + if (!File.Exists(dbPath)) ActiveRecordStarter.CreateSchema(); CreateTrigger(); } + + private static void MigrateOldDb(string dbPath, string appDataPath) + { + Contract.Requires(!String.IsNullOrWhiteSpace(dbPath)); + Contract.Requires(!String.IsNullOrWhiteSpace(appDataPath)); + + var oldDbPath = Path.Combine(appDataPath, "Pithos", "pithos.db"); + var oldDbInfo = new FileInfo(oldDbPath); + if (oldDbInfo.Exists && !File.Exists(dbPath)) + { + var oldDirectory = oldDbInfo.Directory; + oldDbInfo.MoveTo(dbPath); + oldDirectory.Delete(true); + } + } + private void CreateTrigger() { using (var connection = GetConnection()) -- 1.7.10.4