banshee r5144 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Database



Author: gburt
Date: Fri Mar 20 03:40:05 2009
New Revision: 5144
URL: http://svn.gnome.org/viewvc/banshee?rev=5144&view=rev

Log:
2009-03-19  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
	Update the MetadataHash for tracks that have an unknown artist, album,
	and/or title, fixing a problem where such items got removed and readded to
	devices on every sync (BGO #569379)

Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs	Fri Mar 20 03:40:05 2009
@@ -52,7 +52,7 @@
         // 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 = 26;
+        protected const int CURRENT_VERSION = 27;
         protected const int CURRENT_METADATA_VERSION = 5;
         
 #region Migration Driver
@@ -622,6 +622,27 @@
         
 #endregion
 
+#region Version 27
+
+        [DatabaseVersion (27)]
+        private bool Migrate_27 ()
+        {
+            // One time fixup to MetadataHash now that our unknown metadata is handled properly
+            var tracks_needing_new_hash = DatabaseTrackInfo.Provider.FetchAllMatching (
+                "(CoreTracks.Title IS NULL OR CoreArtists.Name IS NULL OR CoreAlbums.Title IS NULL)"
+            );
+
+            var cmd = new HyenaSqliteCommand ("UPDATE CoreTracks SET MetadataHash = ? WHERE TrackID = ?");
+
+            foreach (DatabaseTrackInfo track in tracks_needing_new_hash) {
+                connection.Execute (cmd, track.MetadataHash, track.TrackId);
+            }
+
+            return true;
+        }
+        
+#endregion
+
 #pragma warning restore 0169
         
 #region Fresh database setup



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