[banshee] Don't update DateUpdated stamp when transient fields change (bgo#585896)



commit f86324f4a31230968c26ec0b501944af83940e71
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date:   Tue Jul 28 00:34:55 2009 +1000

    Don't update DateUpdated stamp when transient fields change (bgo#585896)
    
    Updating it results in file writes on *each* track change when 'write
    metadata' option is turned on. The commit avoids the DateUpdated stamp
    getting updated when PlayCount and other transient fields are changed.

 .../DatabaseTrackInfo.cs                           |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
index bec4165..ac58a49 100644
--- a/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
+++ b/src/Core/Banshee.Services/Banshee.Collection.Database/DatabaseTrackInfo.cs
@@ -27,6 +27,7 @@
 //
 
 using System;
+using System.Collections.Generic;
 using System.Data;
 using System.IO;
 
@@ -126,6 +127,16 @@ namespace Banshee.Collection.Database
             Save (NotifySaved);
         }
 
+        // Changing these fields shouldn't change DateUpdated (which triggers file save)
+        private static HashSet<QueryField> transient_fields = new HashSet<QueryField> {
+            BansheeQuery.ScoreField,
+            BansheeQuery.SkipCountField,
+            BansheeQuery.LastSkippedField,
+            BansheeQuery.PlayCountField,
+            BansheeQuery.LastPlayedField,
+            BansheeQuery.RatingField
+        };
+
         public void Save (bool notify, params QueryField [] fields_changed)
         {
             // If either the artist or album changed, 
@@ -139,10 +150,14 @@ namespace Banshee.Collection.Database
                 // TODO get rid of unused artists/albums
             }
             
-            DateUpdated = DateTime.Now;
+            if (fields_changed.Length == 0 || !transient_fields.IsSupersetOf (fields_changed)) {
+                DateUpdated = DateTime.Now;
+            }
 
             bool is_new = (TrackId == 0);
-            if (is_new) DateAdded = DateUpdated;
+            if (is_new) {
+                DateAdded = DateUpdated = DateTime.Now;
+            }
 
             ProviderSave ();
 



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