remove files from AVATAR_PATH when contacts changes his avatar or removes it
This commit is contained in:
parent
3a1e5c579d
commit
6ceb13430b
|
@ -307,6 +307,12 @@ class Connection:
|
||||||
not self.vcard_shas.has_key(frm) or \
|
not self.vcard_shas.has_key(frm) or \
|
||||||
avatar_sha != self.vcard_shas[frm]):
|
avatar_sha != self.vcard_shas[frm]):
|
||||||
gajim.interface.save_avatar_files(frm, photo_decoded)
|
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 frm != our_jid:
|
||||||
if avatar_sha:
|
if avatar_sha:
|
||||||
|
|
|
@ -911,6 +911,11 @@ class Interface:
|
||||||
def save_avatar_files(self, jid, photo_decoded):
|
def save_avatar_files(self, jid, photo_decoded):
|
||||||
'''Save the decoded avatar to a separate file, and generate files for dbus notifications'''
|
'''Save the decoded avatar to a separate file, and generate files for dbus notifications'''
|
||||||
path_to_file = os.path.join(gajim.AVATAR_PATH, jid)
|
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,
|
pixbuf, typ = gtkgui_helpers.get_pixbuf_from_data(photo_decoded,
|
||||||
want_type = True)
|
want_type = True)
|
||||||
if typ not in ('jpeg', 'png'):
|
if typ not in ('jpeg', 'png'):
|
||||||
|
|
Loading…
Reference in New Issue