private string GetXdgDir(string type) { try { return(XdgBaseDirectorySpec.GetXdgDirectoryUnderHome(String.Format("XDG_{0}_DIR", type), null)); } catch { return(null); } }
static GnomeApplication() { dataDir = Path.Combine(XdgBaseDirectorySpec.GetUserDirectory("XDG_DATA_HOME", Path.Combine(".local", "share")), tomboyDirName); confDir = Path.Combine(XdgBaseDirectorySpec.GetUserDirectory("XDG_CONFIG_HOME", ".config"), tomboyDirName); cacheDir = Path.Combine(XdgBaseDirectorySpec.GetUserDirectory("XDG_CACHE_HOME", ".cache"), tomboyDirName); // NOTE: Other directories created on demand // (non-existence is an indicator that migration is needed) if (!Directory.Exists(cacheDir)) { Directory.CreateDirectory(cacheDir); } }
private void MigrateLegacyDb() { string db_path = Paths.Combine(XdgBaseDirectorySpec.GetUserDirectory("XDG_CACHE_HOME", ".cache"), "banshee-mirage", "mirage.db"); var db_uri = new SafeUri(db_path); if (!Banshee.IO.File.Exists(db_uri)) { return; } long analysis_count = ServiceManager.DbConnection.Query <long> (String.Format("SELECT COUNT(*) FROM {0}", TrackAnalysis.Provider.TableName)); if (analysis_count > 0) { return; } try { // Copy the external db's data into the main banshee.db var db = ServiceManager.DbConnection; db.Execute("ATTACH DATABASE ? AS Mirage", db_path); db.Execute(String.Format("INSERT INTO {0} (TrackID, ScmsData, Status) SELECT trackid, scms, 0 FROM Mirage.mirage", TrackAnalysis.Provider.TableName)); db.Execute("DETACH DATABASE Mirage"); Banshee.IO.Utilities.DeleteFileTrimmingParentDirectories(db_uri); // Migrate the status info from the already-local MirageProcessed table if (db.TableExists("MirageProcessed")) { db.Execute(String.Format( @"INSERT OR IGNORE INTO {0} (TrackID, ScmsData, Status) SELECT TrackID, NULL, CASE Status WHEN 0 THEN 0 WHEN -1 THEN {1} WHEN -2 THEN {2} END FROM MirageProcessed WHERE Status != 0", TrackAnalysis.Provider.TableName, (int)AnalysisStatus.Failed, (int)AnalysisStatus.UnknownFailure )); db.Execute("DROP TABLE MirageProcessed"); } } catch (Exception e) { Log.Exception("Failed to migrate old Mirage database", e); } }