From e8a7b128464d03c8357e32ef6dcc842023e139d7 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Sat, 17 Sep 2011 17:24:30 +0100 Subject: [PATCH] =?utf8?q?Bug=20658531=20=E2=80=94=20Sometimes=20avatar=20?= =?utf8?q?caching=20doesn't=20work?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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); } -- 2.7.4