From 6ceb13430bf8fdf0e6a0132afb02d70bf6089e06 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 6 Feb 2006 16:04:55 +0000 Subject: [PATCH] remove files from AVATAR_PATH when contacts changes his avatar or removes it --- src/common/connection.py | 6 ++++++ src/gajim.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/common/connection.py b/src/common/connection.py index d8d958bd8..763caebef 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -307,6 +307,12 @@ class Connection: not self.vcard_shas.has_key(frm) or \ avatar_sha != self.vcard_shas[frm]): gajim.interface.save_avatar_files(frm, photo_decoded) + else: + for ext in ('.jpeg', '.png', '_notif_size_bw.png', + '_notif_size_colored.png'): + path = os.path.join(gajim.AVATAR_PATH, frm + ext) + if os.path.isfile(path): + os.remove(path) if frm != our_jid: if avatar_sha: diff --git a/src/gajim.py b/src/gajim.py index 6715e3186..00d2d050f 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -911,6 +911,11 @@ class Interface: def save_avatar_files(self, jid, photo_decoded): '''Save the decoded avatar to a separate file, and generate files for dbus notifications''' path_to_file = os.path.join(gajim.AVATAR_PATH, jid) + # remove old avatars + for typ in ('jpeg', 'png'): + path_to_original_file = path_to_file + '.' + typ + if os.path.isfile(path_to_original_file): + os.remove(path_to_original_file) pixbuf, typ = gtkgui_helpers.get_pixbuf_from_data(photo_decoded, want_type = True) if typ not in ('jpeg', 'png'):