frontend/cli: fix download command failing after indexing first preset

This commit is contained in:
tfuxu 2022-12-18 18:59:43 +01:00
parent 1e8de798db
commit 354010ae22
No known key found for this signature in database
GPG key ID: 79CFC3B9B31C098A

View file

@ -279,6 +279,8 @@ class CLI:
_preset_name = args.preset_name _preset_name = args.preset_name
#_custom_url = args.custom_url #_custom_url = args.custom_url
repo_no = 1
repos_amount = len(preset_repos.items())
for repo_name, repo in preset_repos.items(): for repo_name, repo in preset_repos.items():
try: try:
explore_presets, urls = PresetDownloader().fetch_presets(repo) explore_presets, urls = PresetDownloader().fetch_presets(repo)
@ -286,6 +288,8 @@ class CLI:
logging.error(f"An error occurred while fetching presets from remote repository. Exc: {e}") logging.error(f"An error occurred while fetching presets from remote repository. Exc: {e}")
exit(1) exit(1)
else: else:
preset_no = 1
presets_amount = len(explore_presets.items())
for (preset, preset_name), preset_url in zip(explore_presets.items(), urls): for (preset, preset_name), preset_url in zip(explore_presets.items(), urls):
# TODO: Add handling of two or more presets with the same elements in name # TODO: Add handling of two or more presets with the same elements in name
if _preset_name.lower() in preset_name.lower(): if _preset_name.lower() in preset_name.lower():
@ -297,9 +301,14 @@ class CLI:
exit(1) exit(1)
else: else:
logging.info("Preset downloaded successfully.") logging.info("Preset downloaded successfully.")
exit(0)
else: else:
logging.error(f"No presets found with text: {_preset_name}") if repo_no == repos_amount and preset_no == presets_amount:
exit(1) logging.error(f"No presets found with text: {_preset_name}")
exit(1)
preset_no += 1
continue
repo_no += 1
# TODO: Fix support for Flatpak builds \ # TODO: Fix support for Flatpak builds \
# Current issue: Monet class can't generate Monet palette from image located in host, because it doesn't have any permissions to read user directories. \ # Current issue: Monet class can't generate Monet palette from image located in host, because it doesn't have any permissions to read user directories. \