From 2ad8d1f3cb5d3421e6e971c0d4a1ecc9fe7838ee Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Thu, 17 Nov 2022 10:57:39 +0000 Subject: [PATCH] Bug 1666491 - Pre: Delete failed (likely partially) processed artifacts. r=firefox-build-system-reviewers,glandium It's possible that the processed file has not been created. Differential Revision: https://phabricator.services.mozilla.com/D162073 --- python/mozbuild/mozbuild/artifacts.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/python/mozbuild/mozbuild/artifacts.py b/python/mozbuild/mozbuild/artifacts.py index e267013777d6..67fb04d84559 100644 --- a/python/mozbuild/mozbuild/artifacts.py +++ b/python/mozbuild/mozbuild/artifacts.py @@ -1392,7 +1392,15 @@ https://firefox-source-docs.mozilla.org/contributing/vcs/mercurial_bundles.html {"processed_filename": processed_filename}, "Writing processed {processed_filename}", ) - self._artifact_job.process_artifact(filename, processed_filename) + try: + self._artifact_job.process_artifact(filename, processed_filename) + except Exception as e: + # Delete the partial output of failed processing. + try: + os.remove(processed_filename) + except FileNotFoundError: + pass + raise e self._artifact_cache._persist_limit.register_file(processed_filename)