mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-10-09 02:41:06 +03:00
Avoid possible crashes
* No 160 dpi icon available * Trying to resize a non-existing icon * Non-dpi icon being lower density than ldpi
This commit is contained in:
parent
77b6974303
commit
f37d00507b
1 changed files with 8 additions and 4 deletions
|
@ -278,6 +278,9 @@ def delete_disabled_builds(apps, apkcache, repodirs):
|
||||||
|
|
||||||
def resize_icon(iconpath, density):
|
def resize_icon(iconpath, density):
|
||||||
|
|
||||||
|
if not os.path.isfile(iconpath):
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
im = Image.open(iconpath)
|
im = Image.open(iconpath)
|
||||||
size = dpi_to_px(density)
|
size = dpi_to_px(density)
|
||||||
|
@ -498,7 +501,7 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
||||||
for density in densities:
|
for density in densities:
|
||||||
if density in thisinfo['icons']:
|
if density in thisinfo['icons']:
|
||||||
break
|
break
|
||||||
if dpi >= int(density):
|
if density == densities[-1] or dpi >= int(density):
|
||||||
thisinfo['icons'][density] = iconfilename
|
thisinfo['icons'][density] = iconfilename
|
||||||
shutil.move(iconpath,
|
shutil.move(iconpath,
|
||||||
os.path.join(get_icon_dir(repodir, density), iconfilename))
|
os.path.join(get_icon_dir(repodir, density), iconfilename))
|
||||||
|
@ -554,9 +557,10 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
||||||
resize_icon(icondest, density)
|
resize_icon(icondest, density)
|
||||||
|
|
||||||
# Copy from icons-mdpi to icons since mdpi is the baseline density
|
# Copy from icons-mdpi to icons since mdpi is the baseline density
|
||||||
shutil.copyfile(
|
baseline = os.path.join(get_icon_dir(repodir, '160'), iconfilename)
|
||||||
os.path.join(get_icon_dir(repodir, '160'), iconfilename),
|
if os.path.isfile(baseline):
|
||||||
os.path.join(get_icon_dir(repodir, None), iconfilename))
|
shutil.copyfile(baseline,
|
||||||
|
os.path.join(get_icon_dir(repodir, None), iconfilename))
|
||||||
|
|
||||||
# Record in known apks, getting the added date at the same time..
|
# Record in known apks, getting the added date at the same time..
|
||||||
added = knownapks.recordapk(thisinfo['apkname'], thisinfo['id'])
|
added = knownapks.recordapk(thisinfo['apkname'], thisinfo['id'])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue