Skip to content

Commit d3e72d1

Browse files
authored
improve(plugins_sync): handle cases where a downloaded plugin is not a valid ZIP (#577)
2 parents c276081 + 97b1dbd commit d3e72d1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

qgis_deployment_toolbelt/jobs/job_plugins_synchronizer.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# Standard library
1515
import logging
1616
from pathlib import Path
17-
from shutil import unpack_archive
17+
from shutil import ReadError, unpack_archive
1818

1919
# package
2020
from qgis_deployment_toolbelt.jobs.generic_job import GenericJob
@@ -215,7 +215,18 @@ def install_plugin_into_profile(
215215
# make sure destination folder exists
216216
profile_plugins_folder.mkdir(parents=True, exist_ok=True)
217217

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

220231
logger.info(
221232
f"Profile {profile.name} - "

0 commit comments

Comments
 (0)