banshee r3339 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Database
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3339 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Database
- Date: Wed, 27 Feb 2008 21:43:42 +0000 (GMT)
Author: gburt
Date: Wed Feb 27 21:43:41 2008
New Revision: 3339
URL: http://svn.gnome.org/viewvc/banshee?rev=3339&view=rev
Log:
2008-02-27 Gabriel Burt <gabriel burt gmail com>
* src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
Improve the metadata refresh process - use the existing OnSlow* calls in
the migrator, don't die if a track can't be refreshed, etc.
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 Wed Feb 27 21:43:41 2008
@@ -452,7 +452,7 @@
if (args.Service is UserJobManager) {
ServiceManager.ServiceStarted -= OnServiceStarted;
if (ServiceManager.SourceManager.Library != null) {
- new RefreshMetadataJob ();
+ RefreshMetadata ();
} else {
ServiceManager.SourceManager.SourceAdded += OnSourceAdded;
}
@@ -463,39 +463,52 @@
{
if (args.Source is Banshee.Library.LibrarySource) {
ServiceManager.SourceManager.SourceAdded -= OnSourceAdded;
- new RefreshMetadataJob ();
+ RefreshMetadata ();
}
}
- private class RefreshMetadataJob : UserJob
+ private void RefreshMetadata ()
{
- public RefreshMetadataJob () : base ("Refreshing Metadata", "Refreshing Metadata", "Preparing...")
- {
- Register ();
- CanCancel = false;
+ OnSlowStarted("Getting new metadata for existing tracks",
+ "This operation may take a few minutes, but the wait will be well worth it!");
+
+ Thread thread = new Thread (RefreshMetadataJob);
+ thread.Start();
+
+ while (thread.IsAlive) {
+ OnSlowPulse ();
+ Thread.Sleep (100);
+ }
+
+ OnSlowFinished();
+ }
- Banshee.Library.LibrarySource library = ServiceManager.SourceManager.Library;
- int total = ServiceManager.DbConnection.Query<int> ("SELECT count(*) FROM CoreTracks WHERE SourceID = 1");
- long now = DateTimeUtil.FromDateTime (DateTime.Now);
+ private void RefreshMetadataJob ()
+ {
+ Banshee.Library.LibrarySource library = ServiceManager.SourceManager.Library;
+ int total = ServiceManager.DbConnection.Query<int> ("SELECT count(*) FROM CoreTracks WHERE SourceID = 1");
+ long now = DateTimeUtil.FromDateTime (DateTime.Now);
- HyenaSqliteCommand select_command = new HyenaSqliteCommand (
- String.Format (
- "SELECT {0} FROM {1} WHERE {2} AND CoreTracks.SourceID = 1",
- DatabaseTrackInfo.Provider.Select,
- DatabaseTrackInfo.Provider.From,
- DatabaseTrackInfo.Provider.Where
- )
- );
+ HyenaSqliteCommand select_command = new HyenaSqliteCommand (
+ String.Format (
+ "SELECT {0} FROM {1} WHERE {2} AND CoreTracks.SourceID = 1",
+ DatabaseTrackInfo.Provider.Select,
+ DatabaseTrackInfo.Provider.From,
+ DatabaseTrackInfo.Provider.Where
+ )
+ );
- int count = 0;
- using (System.Data.IDataReader reader = ServiceManager.DbConnection.Query (select_command)) {
- while (reader.Read ()) {
- Progress = ++count / total;
- DatabaseTrackInfo track = DatabaseTrackInfo.Provider.Load (reader, 0);
- Status = String.Format ("Updating {0} - {1}", track.ArtistName, track.TrackTitle);
+ int count = 0;
+ using (System.Data.IDataReader reader = ServiceManager.DbConnection.Query (select_command)) {
+ while (reader.Read ()) {
+ DatabaseTrackInfo track = null;
+ try {
+ track = DatabaseTrackInfo.Provider.Load (reader, 0);
TagLib.File file = StreamTagger.ProcessUri (track.Uri);
StreamTagger.TrackInfoMerge (track, file);
track.Save ();
+ } catch (Exception e) {
+ Log.Warning (String.Format ("Failed to update metadata for {0}", track.Uri), e.GetType ().ToString ());
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]