=?utf-8?q?=5Bfolks=5D_Bug_658531_=E2=80=94_Sometimes_avatar_caching_doesn?= =?utf-8?q?=27t_work?=



commit e8a7b128464d03c8357e32ef6dcc842023e139d7
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Sep 17 17:24:30 2011 +0100

    Bug 658531 â Sometimes avatar caching doesn't work
    
    Work around bug #659324 (in GIO) to ensure that we never close the same FD
    more than once when storing avatars to the cache.
    
    Closes: bgo#658531

 NEWS                    |    1 +
 folks/avatar-cache.vala |   20 ++++++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/NEWS b/NEWS
index 288a184..5aca361 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,7 @@ Bugs fixed:
 * Bug 659095 â Don't distribute typelib file
 * Bug 659128 â If a persona store goes away we don't remove its personas
 * Bug 657141 â Backend should ask eds for the default backend, not hardcode it
+* Bug 658531 â Sometimes avatar caching doesn't work
 
 API changes:
 * Individual.avatar is now settable using Individual.change_avatar() (not new
diff --git a/folks/avatar-cache.vala b/folks/avatar-cache.vala
index 844d0db..4be9ef3 100644
--- a/folks/avatar-cache.vala
+++ b/folks/avatar-cache.vala
@@ -125,21 +125,22 @@ public class Folks.AvatarCache : Object
       debug ("Storing avatar '%s' in file '%s'.", id,
           dest_avatar_file.get_uri ());
 
+      InputStream src_avatar_stream =
+          yield avatar.load_async (-1, null, null);
+
       // Copy the icon data into a file
       while (true)
         {
-          InputStream src_avatar_stream =
-              yield avatar.load_async (-1, null, null);
+          OutputStream? dest_avatar_stream = null;
 
           try
             {
-              OutputStream dest_avatar_stream =
+              dest_avatar_stream =
                   yield dest_avatar_file.replace_async (null, false,
                       FileCreateFlags.PRIVATE);
-
               yield dest_avatar_stream.splice_async (src_avatar_stream,
-                  OutputStreamSpliceFlags.CLOSE_SOURCE |
-                      OutputStreamSpliceFlags.CLOSE_TARGET);
+                  OutputStreamSpliceFlags.NONE);
+              yield dest_avatar_stream.close_async ();
 
               break;
             }
@@ -153,10 +154,17 @@ public class Folks.AvatarCache : Object
                   continue;
                 }
 
+              if (dest_avatar_stream != null)
+                {
+                  yield dest_avatar_stream.close_async ();
+                }
+
               throw e;
             }
         }
 
+      yield src_avatar_stream.close_async ();
+
       return this.build_uri_for_avatar (id);
     }
 



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