[banshee] Preventing an infinite loop when saving track metadata (BGO #579370)



commit 4a47b84cf4bf2114689ee650db58a135c25bbd61
Author: Alexander Kojevnikov <alexander kojevnikov com>
Date:   Sat Apr 25 11:02:36 2009 +1000

    Preventing an infinite loop when saving track metadata (BGO #579370)
---
 .../Banshee.Base/Tests/TaglibReadWriteTests.cs     |    3 ++-
 .../Banshee.Core/Banshee.Streaming/StreamTagger.cs |    7 ++++---
 .../Banshee.Metadata/SaveTrackMetadataJob.cs       |    3 +--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/Core/Banshee.Core/Banshee.Base/Tests/TaglibReadWriteTests.cs b/src/Core/Banshee.Core/Banshee.Base/Tests/TaglibReadWriteTests.cs
index af568d4..453bf72 100644
--- a/src/Core/Banshee.Core/Banshee.Base/Tests/TaglibReadWriteTests.cs
+++ b/src/Core/Banshee.Core/Banshee.Base/Tests/TaglibReadWriteTests.cs
@@ -121,7 +121,8 @@ namespace Banshee.Base.Tests
             track.Year = 1999;
     
             // Save changes
-            StreamTagger.SaveToFile (track);
+            bool saved = StreamTagger.SaveToFile (track);
+            Assert.IsTrue (saved);
     
             // Read changes
             file = StreamTagger.ProcessUri (uri);
diff --git a/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs b/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
index 153f02d..c58a740 100644
--- a/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
+++ b/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
@@ -222,19 +222,19 @@ namespace Banshee.Streaming
             }
         }
 
-        public static void SaveToFile (TrackInfo track)
+        public static bool SaveToFile (TrackInfo track)
         {
             // FIXME taglib# does not seem to handle writing metadata to video files well at all atm
             // so not allowing
             if ((track.MediaAttributes & TrackMediaAttributes.VideoStream) != 0) {
                 Hyena.Log.DebugFormat ("Avoiding 100% cpu bug with taglib# by not writing metadata to video file {0}", track);
-                return;
+                return false;
             }
         
             // Note: this should be kept in sync with the metadata read in StreamTagger.cs
             TagLib.File file = ProcessUri (track.Uri);
             if (file == null) {
-                return;
+                return false;
             }
             
             file.Tag.Performers = new string [] { track.ArtistName };
@@ -267,6 +267,7 @@ namespace Banshee.Streaming
             track.FileSize = Banshee.IO.File.GetSize (track.Uri);
             track.FileModifiedStamp = Banshee.IO.File.GetModifiedTime (track.Uri);
             track.LastSyncedStamp = DateTime.Now;
+            return true;
         }
     
         public static void TrackInfoMerge (TrackInfo track, StreamTag tag)
diff --git a/src/Core/Banshee.Services/Banshee.Metadata/SaveTrackMetadataJob.cs b/src/Core/Banshee.Services/Banshee.Metadata/SaveTrackMetadataJob.cs
index bdcdac3..6b1ed8b 100644
--- a/src/Core/Banshee.Services/Banshee.Metadata/SaveTrackMetadataJob.cs
+++ b/src/Core/Banshee.Services/Banshee.Metadata/SaveTrackMetadataJob.cs
@@ -77,8 +77,7 @@ namespace Banshee.Metadata
             try {
                 if (WriteEnabled) {
                     Hyena.Log.DebugFormat ("Saving metadata for {0}", track);
-                    StreamTagger.SaveToFile (track);
-                    wrote = true;
+                    wrote = StreamTagger.SaveToFile (track);
                 }
 
                 if (RenameEnabled) {



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