banshee r5160 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Database
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r5160 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Database
- Date: Wed, 25 Mar 2009 00:03:09 +0000 (UTC)
Author: gburt
Date: Wed Mar 25 00:03:09 2009
New Revision: 5160
URL: http://svn.gnome.org/viewvc/banshee?rev=5160&view=rev
Log:
2009-03-24 Gabriel Burt <gabriel burt gmail com>
* src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
* src/Core/Banshee.Services/Banshee.Database/BansheeModelProvider.cs:
Patch from Alexander Kojevnikov and myself fixing an issue with migration
caused by using a SqliteModelProvider within the migrations which assume
the schema has already been updated.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeModelProvider.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 Wed Mar 25 00:03:09 2009
@@ -29,6 +29,7 @@
using System;
using System.Data;
using System.Reflection;
+using System.Text;
using System.Threading;
using Mono.Unix;
@@ -628,14 +629,33 @@
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)"
- );
+ string sql_select = @"
+ SELECT t.TrackID, al.Title, ar.Name, t.Duration,
+ t.Genre, t.Title, t.TrackNumber, t.Year
+ FROM CoreTracks AS t
+ JOIN CoreAlbums AS al ON al.AlbumID=t.AlbumID
+ JOIN CoreArtists AS ar ON ar.ArtistID=t.ArtistID
+ WHERE t.Title IS NULL OR ar.Name IS NULL OR al.Title IS NULL
+ ";
- var cmd = new HyenaSqliteCommand ("UPDATE CoreTracks SET MetadataHash = ? WHERE TrackID = ?");
+ HyenaSqliteCommand sql_update = new HyenaSqliteCommand (@"
+ UPDATE CoreTracks SET MetadataHash = ? WHERE TrackID = ?
+ ");
- foreach (DatabaseTrackInfo track in tracks_needing_new_hash) {
- connection.Execute (cmd, track.MetadataHash, track.TrackId);
+ StringBuilder sb = new StringBuilder ();
+ using (var reader = new HyenaDataReader (connection.Query (sql_select))) {
+ while (reader.Read ()) {
+ sb.Length = 0;
+ sb.Append (reader.Get<string> (1));
+ sb.Append (reader.Get<string> (2));
+ sb.Append ((int)reader.Get<TimeSpan> (3).TotalSeconds);
+ sb.Append (reader.Get<string> (4));
+ sb.Append (reader.Get<string> (5));
+ sb.Append (reader.Get<int> (6));
+ sb.Append (reader.Get<int> (7));
+ string hash = Hyena.CryptoUtil.Md5Encode (sb.ToString (), System.Text.Encoding.UTF8);
+ connection.Execute (sql_update, hash, reader.Get<int> (0));
+ }
}
return true;
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeModelProvider.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeModelProvider.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeModelProvider.cs Wed Mar 25 00:03:09 2009
@@ -39,7 +39,7 @@
// Used for disabling table-checks during testing
internal static class BansheeDatabaseSettings
{
- internal static bool CheckTables = true;
+ internal static bool CheckTables = false;
}
public class BansheeModelProvider<T> : SqliteModelProvider<T> where T : new ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]