Skip to content

Commit

Permalink
improve(plugins_sync): handle cases where a downloaded lpugin is not …
Browse files Browse the repository at this point in the history
…really a zip
  • Loading branch information
Guts committed Nov 28, 2024
1 parent 242d11a commit 8951834
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 8951834

Please sign in to comment.