[banshee] [metadata] Close TagLib.File's stream when finished



commit f5f7d4f3dc75a5354b906e931dd17e2d592c3cb9
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Thu Mar 18 15:14:48 2010 -0700

    [metadata] Close TagLib.File's stream when finished
    
    Should also help with keeping more files open than we intend to.  File
    should really probably be IDisposable instead of doing it this way.

 .../Banshee.Core/Banshee.Streaming/StreamTagger.cs |    2 ++
 .../Banshee.Metadata.Embedded/EmbeddedQueryJob.cs  |    8 +++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs b/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
index 1335575..6338afe 100644
--- a/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
+++ b/src/Core/Banshee.Core/Banshee.Streaming/StreamTagger.cs
@@ -189,6 +189,7 @@ namespace Banshee.Streaming
                     track.Rating = Choose (file_rating, track.Rating, preferTrackInfo);
                     track.PlayCount = Choose (file_playcount, track.PlayCount, preferTrackInfo);
                 }
+                file.Mode = TagLib.File.AccessMode.Closed;
             } else {
                 track.MediaAttributes = TrackMediaAttributes.AudioStream;
                 if (track.Uri != null && VideoExtensions.IsMatchingFile (track.Uri.AbsoluteUri)) {
@@ -321,6 +322,7 @@ namespace Banshee.Streaming
             }
 
             file.Save ();
+            file.Mode = TagLib.File.AccessMode.Closed;
 
             track.FileSize = Banshee.IO.File.GetSize (track.Uri);
             track.FileModifiedStamp = Banshee.IO.File.GetModifiedTime (track.Uri);
diff --git a/src/Core/Banshee.Services/Banshee.Metadata.Embedded/EmbeddedQueryJob.cs b/src/Core/Banshee.Services/Banshee.Metadata.Embedded/EmbeddedQueryJob.cs
index c4a7512..cc4ab5a 100644
--- a/src/Core/Banshee.Services/Banshee.Metadata.Embedded/EmbeddedQueryJob.cs
+++ b/src/Core/Banshee.Services/Banshee.Metadata.Embedded/EmbeddedQueryJob.cs
@@ -89,7 +89,13 @@ namespace Banshee.Metadata.Embedded
         protected IPicture [] GetEmbeddedPictures(SafeUri uri)
         {
             TagLib.File file = StreamTagger.ProcessUri(uri);
-            return file == null ? null : file.Tag.Pictures;
+            if (file != null) {
+                var pics = file.Tag.Pictures;
+                file.Mode = TagLib.File.AccessMode.Closed;
+                return pics;
+            }
+
+            return null;
         }
 
         protected int GetPictureIndexToUse(IPicture [] pictures)



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