Skip to content

Commit

Permalink
improve(plugins_sync): handle cases where a downloaded plugin is not …
Browse files Browse the repository at this point in the history
…a valid ZIP (#577)
  • Loading branch information
Guts authored Nov 29, 2024
2 parents c276081 + 97b1dbd commit d3e72d1
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions qgis_deployment_toolbelt/jobs/job_plugins_synchronizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# Standard library
import logging
from pathlib import Path
from shutil import unpack_archive
from shutil import ReadError, unpack_archive

# package
from qgis_deployment_toolbelt.jobs.generic_job import GenericJob
Expand Down Expand Up @@ -215,7 +215,18 @@ def install_plugin_into_profile(
# make sure destination folder exists
profile_plugins_folder.mkdir(parents=True, exist_ok=True)

unpack_archive(filename=source_path, extract_dir=profile_plugins_folder)
# in some cases related to proxies issues, the plugin archive download
# returns a success but in fact it's just some HTML error from the proxy
# (but with wrong HTTP error code...) so the ZIP file is not really a zip...
try:
unpack_archive(filename=source_path, extract_dir=profile_plugins_folder)
except ReadError as err:
logger.error(
f"Plugin {plugin.name} ({plugin.version}) could not be unzipped nor "
f"installed in profile {profile.name}. Probably because of corrupted "
f"zip file. Is the plugin download worked before? Trace: {err}"
)
continue

logger.info(
f"Profile {profile.name} - "
Expand Down

0 comments on commit d3e72d1

Please sign in to comment.