From 78e00d781ba8979634fa1677eafb80b303c61a0d Mon Sep 17 00:00:00 2001 From: nicko170 Date: Thu, 4 May 2023 22:35:30 +1000 Subject: [PATCH] Ensure tmp files are deleted on failed import (#765) --- irrd/mirroring/mirror_runners_import.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/irrd/mirroring/mirror_runners_import.py b/irrd/mirroring/mirror_runners_import.py index 1674cc3fb..7672c86f9 100644 --- a/irrd/mirroring/mirror_runners_import.py +++ b/irrd/mirroring/mirror_runners_import.py @@ -262,9 +262,12 @@ def run( database_handler=database_handler, roa_validator=roa_validator, ) - p.run_import() - if to_delete: - os.unlink(import_filename) + try: + p.run_import() + finally: + if to_delete: + os.unlink(import_filename) + if import_serial: database_handler.record_serial_newest_mirror(self.source, import_serial)