summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDjLegolas <djlegolas@protonmail.com>2022-01-05 02:08:35 +0200
committerCalum Lind <calumlind+deluge@gmail.com>2022-01-06 10:04:22 +0000
commitfca08cf5835a65f37528fa491dfaf2840e99e315 (patch)
treee5da49001f6509971854034edeb3b6273a8eb136
parent517b2c653b6fed4b4a9ef5a8e866cc7aa4bd771d (diff)
downloaddeluge-fca08cf5835a65f37528fa491dfaf2840e99e315.tar.gz
deluge-fca08cf5835a65f37528fa491dfaf2840e99e315.tar.bz2
deluge-fca08cf5835a65f37528fa491dfaf2840e99e315.zip
[TrackerIcon] Fixed old-large icon removal
After downloading and resizing the new icon, we try to remove the downloaded file, which is larger, but it fails because it tries to do so when the file is still open, and therefor locked. On close of the UI, we got `PermissionError` exceptions for each new icon.
-rw-r--r--deluge/ui/tracker_icons.py7
1 files changed, 5 insertions, 2 deletions
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):