From c17aeb5231781393ceb9901c41b10043f0c1caf8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20P=C3=B6hn?= Date: Sat, 16 Dec 2017 22:06:20 +0100 Subject: [PATCH] fix handling unreadable images in update.extract_apk_icons --- fdroidserver/update.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 782d18fc..3015e337 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -1475,6 +1475,7 @@ def extract_apk_icons(icon_filename, apk, apkzip, repo_dir): icon_path = os.path.join(get_icon_dir(repo_dir, '0'), icon_filename) with open(icon_path, 'wb') as f: f.write(get_icon_bytes(apkzip, icon_src)) + im = None try: im = Image.open(icon_path) dpi = px_to_dpi(im.size[0]) @@ -1491,7 +1492,8 @@ def extract_apk_icons(icon_filename, apk, apkzip, repo_dir): logging.warning(_("Failed reading {path}: {error}") .format(path=icon_path, error=e)) finally: - im.close() + if im: + im.close() if apk['icons']: apk['icon'] = icon_filename -- 2.30.2