Merge branch 'fix_missing_icon' into 'master'

Use default icon for index if the file does not exist

See merge request fdroid/fdroidserver!1374
This commit is contained in:
Jochen Sprickerhof 2024-04-14 09:32:47 +00:00
commit 9c69a97e71
1 changed files with 7 additions and 2 deletions

View File

@ -606,11 +606,16 @@ def load_localized_config(name, repodir):
ret[afname][key] = dict()
if key == "icon":
icons_dir = os.path.join(repodir, 'icons')
# make sure the icon filename contains only a file name
# to restrict files to the config directory.
icon = os.path.basename(value)
if not os.path.exists(icons_dir):
os.makedirs(icons_dir, exist_ok=True)
shutil.copy(os.path.join("config", value), icons_dir)
if not os.path.exists(os.path.join("config", icon)):
ret[afname][key][locale] = ret[afname][key][DEFAULT_LOCALE]
shutil.copy(os.path.join("config", icon), icons_dir)
ret[afname][key][locale] = file_entry(
os.path.join(icons_dir, value)
os.path.join(icons_dir, icon)
)
else:
ret[afname][key][locale] = value