From 8aa5d30831ff3a015ffef96c8bc8c1cd4e56ecb2 Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum <39048939+jnussbaum@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:22:46 +0100 Subject: [PATCH] fix(resume-xmlupload): make it impossible to resume after all resources have been created (DEV-3398) (#865) --- src/dsp_tools/commands/xmlupload/xmlupload.py | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/dsp_tools/commands/xmlupload/xmlupload.py b/src/dsp_tools/commands/xmlupload/xmlupload.py index 8c3f641e4..944f31a71 100644 --- a/src/dsp_tools/commands/xmlupload/xmlupload.py +++ b/src/dsp_tools/commands/xmlupload/xmlupload.py @@ -144,23 +144,25 @@ def cleanup_upload( Returns: success status (deduced from failed_uploads) """ - logfiles = ", ".join([handler.baseFilename for handler in logger.handlers if isinstance(handler, FileHandler)]) write_id2iri_mapping(iri_resolver.lookup, config.diagnostics) if not failed_uploads and not nonapplied_stash: + success = True print(f"{datetime.now()}: All resources have successfully been uploaded.") logger.info("All resources have successfully been uploaded.") - return True - if failed_uploads: - print(f"\n{datetime.now()}: WARNING: Could not upload the following resources: {failed_uploads}\n") - print(f"For more information, see the log file: {logfiles}\n") - logger.warning(f"Could not upload the following resources: {failed_uploads}") - if nonapplied_stash: - print(f"\n{datetime.now()}: WARNING: Could not reapply the following stash items: {nonapplied_stash}\n") - print(f"For more information, see the log file: {logfiles}\n") - logger.warning(f"Could not reapply the following stash items: {nonapplied_stash}") + else: + success = False + logfiles = ", ".join([handler.baseFilename for handler in logger.handlers if isinstance(handler, FileHandler)]) + if failed_uploads: + print(f"\n{datetime.now()}: WARNING: Could not upload the following resources: {failed_uploads}\n") + print(f"For more information, see the log file: {logfiles}\n") + logger.warning(f"Could not upload the following resources: {failed_uploads}") + if nonapplied_stash: + print(f"\n{datetime.now()}: WARNING: Could not reapply the following stash items: {nonapplied_stash}\n") + print(f"For more information, see the log file: {logfiles}\n") + logger.warning(f"Could not reapply the following stash items: {nonapplied_stash}") config.diagnostics.save_location.unlink(missing_ok=True) - return False + return success def _prepare_upload(