banshee r4335 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Collection src/Core/Banshee.Services/Banshee.Collection.Database src/Core/Banshee.Services/Banshee.Database src/Core/Banshee.Services/Banshee.PlayerMigration src/Core/Banshee.ThickClient/Banshee.Collection.Gui



Author: gburt
Date: Thu Aug  7 19:26:23 2008
New Revision: 4335
URL: http://svn.gnome.org/viewvc/banshee?rev=4335&view=rev

Log:
2008-08-07  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs:
	Make sure no modifiers are set when handling o like enter.

	* src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs:
	Only reload a max of 5 times during a given import; every 250 items or
	20%, whatever is more.

	* src/Core/Banshee.Services/Banshee.Collection/ImportManager.cs: Add a
	protected TotalCount property for the above 20% to use.

	* src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
	Fix bug where the metadata refresh was triggered for brand new databases.

	* src/Core/Banshee.Services/Banshee.PlayerMigration/AmarokPlayerImportSource.cs:
	Fix bug with rounding Amarok's ratings down (eg 7 down to 3, etc), and not
	migrating the added and last played stamps.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/ImportManager.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
   trunk/banshee/src/Core/Banshee.Services/Banshee.PlayerMigration/AmarokPlayerImportSource.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseImportManager.cs	Thu Aug  7 19:26:23 2008
@@ -206,7 +206,10 @@
             }
 
             counts[track.PrimarySourceId] = counts.ContainsKey (track.PrimarySourceId) ? counts[track.PrimarySourceId] + 1 : 1;
-            if (counts[track.PrimarySourceId] % 250 == 0) {
+            
+            // Reload every 20% or every 250 tracks, whatever is more (eg at most reload 5 times during an import)
+            if (counts[track.PrimarySourceId] >= Math.Max (TotalCount/5, 250)) {
+                counts[track.PrimarySourceId] = 0;
                 track.PrimarySource.NotifyTracksAdded ();
             }
 
@@ -227,15 +230,18 @@
             ErrorSource.AddMessage (Path.GetFileName (path), msg);
             Log.Error (path, msg, false);
         }
-
-        protected override void OnImportFinished ()
+        
+        public void NotifyAllSources ()
         {
             foreach (int primary_source_id in counts.Keys) {
                 PrimarySource.GetById (primary_source_id).NotifyTracksAdded ();
             }
-
             counts.Clear ();
+        }
 
+        protected override void OnImportFinished ()
+        {
+            NotifyAllSources ();
             base.OnImportFinished ();
         }
     }

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/ImportManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/ImportManager.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Collection/ImportManager.cs	Thu Aug  7 19:26:23 2008
@@ -282,6 +282,10 @@
             set { import_element.Threaded = scanner_element.Threaded = value; }
         }
         
+        protected int TotalCount {
+            get { return import_element == null ? 0 : import_element.TotalCount; }
+        }
+        
 #endregion
 
     }

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	Thu Aug  7 19:26:23 2008
@@ -508,7 +508,7 @@
                 )
             ");
             Execute (String.Format ("INSERT INTO CoreConfiguration VALUES (null, 'DatabaseVersion', {0})", CURRENT_VERSION));
-            Execute ("INSERT INTO CoreConfiguration VALUES (null, 'MetadataVersion', 0)");
+            Execute (String.Format ("INSERT INTO CoreConfiguration VALUES (null, 'MetadataVersion', {0})", CURRENT_METADATA_VERSION));
             
             Execute(@"
                 CREATE TABLE CorePrimarySources (

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.PlayerMigration/AmarokPlayerImportSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.PlayerMigration/AmarokPlayerImportSource.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.PlayerMigration/AmarokPlayerImportSource.cs	Thu Aug  7 19:26:23 2008
@@ -65,21 +65,8 @@
             } catch (Exception) {}
 
             try {
-                conn.Execute (@"
-                    CREATE TEMP TABLE devices_tmp
-                           (id INTEGER PRIMARY KEY,
-                            lastmountpoint VARCHAR(255));
-                    INSERT INTO devices_tmp (id, lastmountpoint)
-                           SELECT devices.id,
-                                  devices.lastmountpoint
-                           FROM devices;
-                    INSERT OR IGNORE INTO devices_tmp (id, lastmountpoint)
-                           VALUES (-1, '/');"
-                );
-                
                 HyenaSqliteCommand cmd = new HyenaSqliteCommand (@"
-                    SELECT DISTINCT
-                           devices_tmp.lastmountpoint,
+                    SELECT DISTINCT NULL,
                            tags.url,
                            tags.title,
                            artist.name,
@@ -87,15 +74,13 @@
                            album.name,
                            year.name,
                            tags.track,
-                           tags.length,
-                           tags.deviceid
+                           tags.length
                      FROM  tags,
-                           devices_tmp,
                            artist,
                            album,
                            genre,
                            year
-                     WHERE tags.deviceid = devices_tmp.id
+                     WHERE tags.deviceid = -1
                        AND tags.artist = artist.id
                        AND tags.album = album.id
                        AND tags.genre = genre.id
@@ -103,9 +88,9 @@
                 );
                 
                 HyenaSqliteCommand stats_cmd = new HyenaSqliteCommand (@"
-                                                     SELECT DISTINCT rating/2, playcounter
+                                                     SELECT DISTINCT (rating+rating%2)/2, playcounter, createdate, accessdate
                                                      FROM   statistics
-                                                     WHERE  accessdate > 0 AND url = ? AND deviceid = ?");
+                                                     WHERE  url = ? AND deviceid = -1");
 
                 int processed = 0;
 
@@ -117,12 +102,11 @@
                      processed++;
 
                      try {
-                         string mountpoint = (string) reader[0];
                          string path = (string) reader[1];
                          
                          SafeUri uri = null;
                          if (path.StartsWith ("./")) {
-                             uri = new SafeUri (Path.Combine (mountpoint, path.Substring (2)));
+                             uri = new SafeUri (path.Substring (1));
                          } else if (path.StartsWith ("/")) {
                              uri = new SafeUri (path);
                          } else {
@@ -131,18 +115,21 @@
 
                          string title = (string) reader[2];
                          string artist = (string) reader[3];
+                         //Console.WriteLine ("Amarok import has {0}/{1} - {2}", artist, title, uri);
                          
                          // the following fields are not critical and can be skipped if something goes wrong
                          int rating = 0, playcount = 0;
+                         long created = 0, accessed = 0;
 
                          // Try to read stats
                          try {
-                             int deviceid = Convert.ToInt32 (reader [9]);
-                             IDataReader stats_reader = conn.Query (stats_cmd, path, deviceid);
+                             IDataReader stats_reader = conn.Query (stats_cmd, path);
 
                              while (stats_reader.Read ()) {
                                  rating = Convert.ToInt32 (stats_reader[0]);
                                  playcount = Convert.ToInt32 (stats_reader[1]);
+                                 created = Convert.ToInt64 (stats_reader[2]);
+                                 accessed = Convert.ToInt64 (stats_reader[3]);
                              }
                              stats_reader.Close ();
                          } catch (Exception) {}
@@ -156,9 +143,13 @@
                                  throw new Exception (String.Format (Catalog.GetString ("Unable to import track: {0}"), uri.AbsoluteUri));
                              }
                             
-                             if (rating > 0 || playcount > 0) {
+                             if (rating > 0 || playcount > 0 || created > 0 || accessed > 0) {
                                  track.Rating = rating;
                                  track.PlayCount = playcount;
+                                 if (created > 0)
+                                     track.DateAdded = Hyena.DateTimeUtil.FromTimeT (created);
+                                 if (accessed > 0)
+                                     track.LastPlayed = Hyena.DateTimeUtil.FromTimeT (accessed);
                                  track.Save (false);
                              }
                          } catch (Exception e) {
@@ -170,6 +161,7 @@
                      }
                  }
                  reader.Close ();
+                 import_manager.NotifyAllSources ();
                  
                  // TODO migrating more than the podcast subscriptions (eg whether to auto sync them etc) means 1) we need to have those features
                  // and 2) we need to depend on Migo and/or the Podcast extension

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs	Thu Aug  7 19:26:23 2008
@@ -32,6 +32,7 @@
 
 using Hyena.Data;
 using Hyena.Data.Gui;
+using Hyena.Gui;
 
 using Banshee.Sources;
 using Banshee.ServiceStack;
@@ -71,7 +72,7 @@
         protected override bool OnKeyPressEvent (Gdk.EventKey press)
         {
             // Have o act the same as enter - activate the selection
-            if (press.Key == Gdk.Key.o && ActivateSelection ()) {
+            if (GtkUtilities.NoImportantModifiersAreSet () && press.Key == Gdk.Key.o && ActivateSelection ()) {
                 return true;
             }
             return base.OnKeyPressEvent (press);



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