[banshee] Look for Rhythmbox db at both new and old paths



commit 8a4276b7b5a89ce7e06029a9ae9a7e4cede5e701
Author: Paul Lange <palango gmx de>
Date:   Fri Jun 5 12:58:44 2009 -0500

    Look for Rhythmbox db at both new and old paths
    
    Signed-off-by: Gabriel Burt <gabriel burt gmail com>
---
 .../RhythmboxPlayerImportSource.cs                 |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/RhythmboxPlayerImportSource.cs b/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/RhythmboxPlayerImportSource.cs
index d4a1e4f..10908f1 100644
--- a/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/RhythmboxPlayerImportSource.cs
+++ b/src/Extensions/Banshee.PlayerMigration/Banshee.PlayerMigration/RhythmboxPlayerImportSource.cs
@@ -48,6 +48,10 @@ namespace Banshee.PlayerMigration
     public sealed class RhythmboxPlayerImportSource : ThreadPoolImportSource
     {
         private static readonly SafeUri rhythmbox_db_uri = new SafeUri (Banshee.Base.Paths.Combine (
+            Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".local", "share", "rhythmbox", "rhythmdb.xml"
+        ));
+
+        private static readonly SafeUri rhythmbox_db_uri_old = new SafeUri (Banshee.Base.Paths.Combine (
             Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".gnome2", "rhythmbox", "rhythmdb.xml"
         ));
 
@@ -57,20 +61,26 @@ namespace Banshee.PlayerMigration
         {
             LibraryImportManager import_manager = ServiceManager.Get<LibraryImportManager> ();
 
-            if (!IsValidXmlDocument (rhythmbox_db_uri)) {
-                LogError (SafeUri.UriToFilename (rhythmbox_db_uri), "Rhythmbox library is corrupted.");
+            SafeUri db_uri = rhythmbox_db_uri;
+            //Check if library is located in the old place (.gnome2/rhythmbox/rhythmdb.db)
+            if (!Banshee.IO.File.Exists (rhythmbox_db_uri)) {
+                db_uri = rhythmbox_db_uri_old;
+            }
+
+            if (!IsValidXmlDocument (db_uri)) {
+                LogError (SafeUri.UriToFilename (db_uri), "Rhythmbox library is corrupted.");
                 return;
             }
 
             // Load Rhythmbox library
-            Stream stream_db = Banshee.IO.File.OpenRead (rhythmbox_db_uri);
+            Stream stream_db = Banshee.IO.File.OpenRead (db_uri);
             XmlDocument xml_doc_db = new XmlDocument ();
             xml_doc_db.Load (stream_db);
             XmlElement db_root = xml_doc_db.DocumentElement;
             stream_db.Close ();
 
             if (db_root == null || !db_root.HasChildNodes || db_root.Name != "rhythmdb") {
-                LogError (SafeUri.UriToFilename (rhythmbox_db_uri), "Unable to open Rhythmbox library.");
+                LogError (SafeUri.UriToFilename (db_uri), "Unable to open Rhythmbox library.");
                 return;
             }
             
@@ -342,7 +352,7 @@ namespace Banshee.PlayerMigration
         }
         
         public override bool CanImport {
-            get { return Banshee.IO.File.Exists (rhythmbox_db_uri); }
+            get { return Banshee.IO.File.Exists (rhythmbox_db_uri) || Banshee.IO.File.Exists (rhythmbox_db_uri_old); }
         }
         
         public override string Name {



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