remove files from AVATAR_PATH when contacts changes his avatar or removes it

This commit is contained in:
Yann Leboulanger 2006-02-06 16:04:55 +00:00
parent 3a1e5c579d
commit 6ceb13430b
2 changed files with 11 additions and 0 deletions

View File

@ -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:

View File

@ -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'):