diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py index 813f82df4..cad5af609 100644 --- a/deluge/ui/tracker_icons.py +++ b/deluge/ui/tracker_icons.py @@ -479,14 +479,17 @@ class TrackerIcons(Component): # Requires Pillow(PIL) to resize. if icon and Image: filename = icon.get_filename() + remove_old = False with Image.open(filename) as img: if img.size > (16, 16): new_filename = filename.rpartition('.')[0] + '.png' img = img.resize((16, 16), Image.ANTIALIAS) img.save(new_filename) if new_filename != filename: - os.remove(filename) - icon = TrackerIcon(new_filename) + remove_old = True + if remove_old: + os.remove(filename) + icon = TrackerIcon(new_filename) return icon def store_icon(self, icon, host):