[banshee] [gapless] Properly save LastPlayed stamp (bgo#612577)



commit 23e80ce330606e267dacac6cbc01e628395ae2f2
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date:   Sat Mar 13 18:12:42 2010 +1100

    [gapless] Properly save LastPlayed stamp (bgo#612577)
    
    Calling track.Save() in OnAboutToFinish() caused DateUpdated stamp
    update which in turn unnecessarily triggered SaveTrackMetadataJob.

 .../Banshee.GStreamer/PlayerEngine.cs              |    3 +--
 .../Banshee.Core/Banshee.Collection/TrackInfo.cs   |    5 +++++
 .../DatabaseTrackInfo.cs                           |    6 ++++++
 3 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
index 04fa99c..1a48c63 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
@@ -318,8 +318,7 @@ namespace Banshee.GStreamer
             //
             // This will be overridden by IncrementLastPlayed () called by
             // PlaybackControllerService's EndOfStream handler.
-            CurrentTrack.LastPlayed = DateTime.Now;
-            CurrentTrack.Save ();
+            CurrentTrack.UpdateLastPlayed ();
 
             next_track_set.Reset ();
             pending_uri = null;
diff --git a/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs b/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
index 5df37a5..c0b05af 100644
--- a/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
+++ b/src/Core/Banshee.Core/Banshee.Collection/TrackInfo.cs
@@ -132,6 +132,11 @@ namespace Banshee.Collection
         {
         }
 
+        public virtual void UpdateLastPlayed ()
+        {
+            LastPlayed = DateTime.Now;
+        }
+
         public bool IsPlaying {
             get { return (IsPlayingMethod != null) ? IsPlayingMethod (this) : false; }
         }
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
index 54a0257..41ff4b1 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
@@ -157,6 +157,12 @@ namespace Banshee.Collection.Database
             Save (NotifySaved);
         }
 
+        public override void UpdateLastPlayed ()
+        {
+            base.UpdateLastPlayed ();
+            Save (NotifySaved, BansheeQuery.LastPlayedField);
+        }
+
         public void Save (bool notify, params QueryField [] fields_changed)
         {
             // If either the artist or album changed,



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