From: Yoann Congal Date: Wed, 6 Aug 2025 15:55:49 +0000 (+0200) Subject: runqemu: refactor a duplicated cleanup statement X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c92399c355d1333eff37ea799832a8890acd0d74;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git runqemu: refactor a duplicated cleanup statement Refactor using a "finally:" instead of a duplicated statement inside and outside of the try/except block. Signed-off-by: Yoann Congal Signed-off-by: Richard Purdie --- diff --git a/scripts/runqemu b/scripts/runqemu index 4fb85177e3..3a339acc2a 100755 --- a/scripts/runqemu +++ b/scripts/runqemu @@ -450,11 +450,10 @@ class BaseConfig(object): try: subprocess.check_call(['zstd', '-d', image_path, '-o', uncompressed_path]) except subprocess.CalledProcessError as e: - self.cleanup_files.append(uncompressed_path) raise RunQemuError(f"Failed to decompress {self.rootfs}: {e}") - - # Mark for deletion at the end - self.cleanup_files.append(uncompressed_path) + finally: + # Mark temporary file for deletion + self.cleanup_files.append(uncompressed_path) # Use the decompressed image as the rootfs self.rootfs = uncompressed_path