From: Daniel Martí Date: Tue, 7 Jan 2014 16:02:59 +0000 (+0100) Subject: Avoid possible crashes X-Git-Tag: 0.1~37 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f37d00507bb51ca73aa5cd7690901f0aabe80482;p=fdroidserver.git Avoid possible crashes * No 160 dpi icon available * Trying to resize a non-existing icon * Non-dpi icon being lower density than ldpi --- diff --git a/fdroidserver/update.py b/fdroidserver/update.py index dd2f8728..2e95d025 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -278,6 +278,9 @@ def delete_disabled_builds(apps, apkcache, repodirs): def resize_icon(iconpath, density): + if not os.path.isfile(iconpath): + return + try: im = Image.open(iconpath) size = dpi_to_px(density) @@ -498,7 +501,7 @@ def scan_apks(apps, apkcache, repodir, knownapks): for density in densities: if density in thisinfo['icons']: break - if dpi >= int(density): + if density == densities[-1] or dpi >= int(density): thisinfo['icons'][density] = iconfilename shutil.move(iconpath, os.path.join(get_icon_dir(repodir, density), iconfilename)) @@ -554,9 +557,10 @@ def scan_apks(apps, apkcache, repodir, knownapks): resize_icon(icondest, density) # Copy from icons-mdpi to icons since mdpi is the baseline density - shutil.copyfile( - os.path.join(get_icon_dir(repodir, '160'), iconfilename), - os.path.join(get_icon_dir(repodir, None), iconfilename)) + baseline = os.path.join(get_icon_dir(repodir, '160'), iconfilename) + if os.path.isfile(baseline): + shutil.copyfile(baseline, + os.path.join(get_icon_dir(repodir, None), iconfilename)) # Record in known apks, getting the added date at the same time.. added = knownapks.recordapk(thisinfo['apkname'], thisinfo['id'])