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())