[banshee] Database: correct URIs imported with buggy Gio backend



commit 0403e1b8a1041ac9d4a95d74b12c89ece6efeeb8
Author: AndrÃs G. Aragoneses <knocte gmail com>
Date:   Wed Nov 9 20:40:26 2011 +0000

    Database: correct URIs imported with buggy Gio backend
    
    Replace URIs of CoreTracks to convert them to the proper encoding,
    to be consistent with URIs of newly imported files, as the previous
    commit fixed the Gio backend.
    
    This effectively makes bugs bgo#631970 and bgo#661100 finally disappear
    for already imported tracks too.
    
    Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>

 .../Banshee.Database/BansheeDbFormatMigrator.cs    |   21 +++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs b/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
index 131393d..f63455d 100644
--- a/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
+++ b/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
@@ -54,7 +54,7 @@ namespace Banshee.Database
         // NOTE: Whenever there is a change in ANY of the database schema,
         //       this version MUST be incremented and a migration method
         //       MUST be supplied to match the new version number
-        protected const int CURRENT_VERSION = 44;
+        protected const int CURRENT_VERSION = 45;
         protected const int CURRENT_METADATA_VERSION = 8;
 
 #region Migration Driver
@@ -958,6 +958,15 @@ namespace Banshee.Database
         }
 #endregion
 
+        [DatabaseVersion (45)]
+        private bool Migrate_45 ()
+        {
+            connection.AddFunction<FixUriEncodingFunction> ();
+            Execute ("UPDATE CoreTracks SET Uri = BANSHEE_FIX_URI_ENCODING (Uri) WHERE Uri LIKE 'file:///%'");
+            connection.RemoveFunction<FixUriEncodingFunction> ();
+            return true;
+        }
+
 #pragma warning restore 0169
 
 #region Fresh database setup
@@ -1490,4 +1499,14 @@ namespace Banshee.Database
             return SafeUri.FilenameToUri (full_path);
         }
     }
+
+    [SqliteFunction (Name = "BANSHEE_FIX_URI_ENCODING", FuncType = FunctionType.Scalar, Arguments = 1)]
+    internal class FixUriEncodingFunction : SqliteFunction
+    {
+        public override object Invoke (object[] args)
+        {
+            string uri = (string)args[0];
+            return SafeUri.FilenameToUri (SafeUri.UriToFilename (uri));
+        }
+    }
 }



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