[banshee] [Dap] Write metadata to copied files if needed



commit 106538a6ea8fb6087b4693041b6767693269eab3
Author: Jack Deslippe <jdeslip jdeslippe com>
Date:   Tue Sep 15 12:03:36 2009 -0700

    [Dap] Write metadata to copied files if needed
    
    This patch fixes the bug where podcasts need to be resynced each time banshee
    restarts by writing the metadata out to file for SyncStamps >= Update Stamps.
    
    It should also fix syncing when the "write metadata to files" flag is off.
    
    Signed-off-by: Gabriel Burt <gabriel burt gmail com>

 .../Banshee.Dap.MassStorage/MassStorageSource.cs   |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
index f319119..b00b145 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
@@ -477,14 +477,24 @@ namespace Banshee.Dap.MassStorage
                 Directory.Create (System.IO.Path.GetDirectoryName (new_uri.LocalPath));
                 File.Copy (fromUri, new_uri, false);
 
-                // TODO If write-to-file is NOT on, then write the metadata in db to the file on the DAP
-                // to ensure that when we load it next time, it's data will match what's in the database
-                // and the MetadataHash will actually match.  This isn't necessary on iPods or MTP since
-                // on them we store our db's metadata in their dbs.
-
                 DatabaseTrackInfo copied_track = new DatabaseTrackInfo (track);
                 copied_track.PrimarySource = this;
                 copied_track.Uri = new_uri;
+
+                // Write the metadata in db to the file on the DAP if it has changed since file was modified
+                // to ensure that when we load it next time, it's data will match what's in the database
+                // and the MetadataHash will actually match.  We do this by comparing the time
+                // stamps on files for last update of the db metadata vs the sync to file.
+                // The equals on the inequality below is necessary for podcasts who often have a sync and
+                // update time that are the same to the second, even though the album metadata has changed in the 
+                // DB to the feedname instead of what is in the file.  It should be noted that writing the metadata
+                // is a small fraction of the total copy time anyway.
+
+                if (track.LastSyncedStamp >= Hyena.DateTimeUtil.ToDateTime (track.FileModifiedStamp)) {
+                    Log.DebugFormat ("Copying Metadata to File Since Sync time >= Updated Time");
+                    Banshee.Streaming.StreamTagger.SaveToFile (copied_track);
+                }
+
                 copied_track.Save (false);
             }
 



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