[banshee] Add ArtworkID column to the CoreAlbums table (bgo#656670)



commit 0e5379cc95b02636371dd8946b95952bfc32103d
Author: Alex Launi <alex launi canonical com>
Date:   Tue Aug 16 12:11:58 2011 -0400

    Add ArtworkID column to the CoreAlbums table (bgo#656670)
    
    Speeds up startup by caching album art hash into the DB.
    
    Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>

 .../Banshee.Core/Banshee.Collection/AlbumInfo.cs   |    5 ++++-
 .../DatabaseAlbumInfo.cs                           |   13 +++++++++++++
 .../Banshee.Database/BansheeDbFormatMigrator.cs    |   17 ++++++++++++++---
 3 files changed, 31 insertions(+), 4 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.Collection/AlbumInfo.cs b/src/Core/Banshee.Core/Banshee.Collection/AlbumInfo.cs
index 8683426..0d9fbc1 100644
--- a/src/Core/Banshee.Core/Banshee.Collection/AlbumInfo.cs
+++ b/src/Core/Banshee.Core/Banshee.Collection/AlbumInfo.cs
@@ -95,11 +95,14 @@ namespace Banshee.Collection
         public virtual string ArtworkId {
             get {
                 if (artwork_id == null) {
-                    artwork_id = CoverArtSpec.CreateArtistAlbumId (ArtistName, Title);
+                    ArtworkId = CoverArtSpec.CreateArtistAlbumId (ArtistName, Title);
                 }
 
                 return artwork_id;
             }
+            set {
+                artwork_id = value;
+            }
         }
 
         public virtual string DisplayArtistName {
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs
index 85558aa..b973796 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseAlbumInfo.cs
@@ -140,6 +140,12 @@ namespace Banshee.Collection.Database
                         save = true;
                     }
 
+                    // If the ArtworkId has changed, update the db
+                    if (last_album.ArtworkId != album.ArtworkId) {
+                        last_album.ArtworkId = album.ArtworkId;
+                        save = true;
+                    }
+
                     if (save) {
                         last_album.Save ();
                     }
@@ -170,6 +176,7 @@ namespace Banshee.Collection.Database
                 album.MusicBrainzId = found.MusicBrainzId;
                 album.dbid = found.DbId;
                 album.ArtistId = found.ArtistId;
+                album.ArtworkId = found.ArtworkId;
                 album.Save ();
             }
             return album;
@@ -209,6 +216,12 @@ namespace Banshee.Collection.Database
             set { base.ReleaseDate = value; }
         }
 
+        [DatabaseColumn("ArtworkID")]
+        public override string ArtworkId {
+            get { return base.ArtworkId; }
+            set { base.ArtworkId = value; }
+        }
+
         [DatabaseColumn]
         public override bool IsCompilation {
             get { return base.IsCompilation; }
diff --git a/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs b/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
index 90cddb6..fb95f26 100644
--- a/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
+++ b/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
@@ -54,8 +54,8 @@ 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 = 43;
-        protected const int CURRENT_METADATA_VERSION = 7;
+        protected const int CURRENT_VERSION = 44;
+        protected const int CURRENT_METADATA_VERSION = 8;
 
 #region Migration Driver
 
@@ -949,6 +949,15 @@ namespace Banshee.Database
             return true;
         }
 
+#region Version 44
+        [DatabaseVersion (44)]
+        private bool Migrate_44 ()
+        {
+            Execute ("ALTER TABLE CoreAlbums ADD COLUMN ArtworkID TEXT");
+            return true;
+        }
+#endregion
+
 #pragma warning restore 0169
 
 #region Fresh database setup
@@ -1074,7 +1083,9 @@ namespace Banshee.Database
                     ArtistNameSort      TEXT,
                     ArtistNameSortKey   BLOB,
 
-                    Rating              INTEGER
+                    Rating              INTEGER,
+
+                    ArtworkID           TEXT
                 )
             ");
             Execute ("CREATE INDEX CoreAlbumsIndex ON CoreAlbums(ArtistID, TitleSortKey)");



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