chiark / gitweb /
fix "cannot identify image file" with XML icons
authorIzzy <izzysoft@qumran.org>
Fri, 12 Jan 2018 21:12:27 +0000 (22:12 +0100)
committerIzzy <izzysoft@qumran.org>
Fri, 12 Jan 2018 21:12:27 +0000 (22:12 +0100)
fdroidserver/update.py

index c1079489cc8f08020d03f26f1bd7f58bcde4decc..c5fa27df56f07ce621ba3538746db98dd8e53cb5 100644 (file)
@@ -1473,6 +1473,12 @@ def extract_apk_icons(icon_filename, apk, apkzip, repo_dir):
     if '-1' in apk['icons_src']:
         icon_src = apk['icons_src']['-1']
         icon_path = os.path.join(get_icon_dir(repo_dir, '0'), icon_filename)
+        if icon_src.endswith('.xml'):
+            for f in apkzip.namelist():
+                if f.endswith(png):
+                    m = re.match(r'res/(drawable|mipmap)-(x*[hlm]dpi).*/', f)
+                    if m:
+                        icon_src = f
         with open(icon_path, 'wb') as f:
             f.write(get_icon_bytes(apkzip, icon_src))
         im = None