Revision 618015f4

b/trunk/Pithos.Core/Agents/StatusAgent.cs
31 31
        public StatusAgent()
32 32
        {            
33 33
            var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
34
            _pithosDataPath = Path.Combine(appDataPath , "Pithos");
34
            
35

  
35 36

  
37
            _pithosDataPath = Path.Combine(appDataPath , "GRNET");
36 38
            if (!Directory.Exists(_pithosDataPath))
37 39
                Directory.CreateDirectory(_pithosDataPath);
40

  
41
            var dbPath = Path.Combine(_pithosDataPath, "pithos.db");
42

  
43
            MigrateOldDb(dbPath, appDataPath);
44

  
38 45
            var source = GetConfiguration(_pithosDataPath);
39 46
            ActiveRecordStarter.Initialize(source,typeof(FileState),typeof(FileTag));
40 47
            ActiveRecordStarter.UpdateSchema();
41
            
42 48

  
43
            if (!File.Exists(Path.Combine(_pithosDataPath ,"pithos.db")))
49

  
50
            if (!File.Exists(dbPath))
44 51
                ActiveRecordStarter.CreateSchema();
45 52

  
46 53
            CreateTrigger();
47 54
            
48 55
        }
49 56

  
57

  
58
        private static void MigrateOldDb(string dbPath, string appDataPath)
59
        {
60
            Contract.Requires(!String.IsNullOrWhiteSpace(dbPath));
61
            Contract.Requires(!String.IsNullOrWhiteSpace(appDataPath));
62

  
63
            var oldDbPath = Path.Combine(appDataPath, "Pithos", "pithos.db");
64
            var oldDbInfo = new FileInfo(oldDbPath);
65
            if (oldDbInfo.Exists && !File.Exists(dbPath))
66
            {
67
                var oldDirectory = oldDbInfo.Directory;
68
                oldDbInfo.MoveTo(dbPath);                
69
                oldDirectory.Delete(true);
70
            }
71
        }
72

  
50 73
        private void CreateTrigger()
51 74
        {
52 75
            using (var connection = GetConnection())

Also available in: Unified diff