runqemu: refactor a duplicated cleanup statement

Refactor using a "finally:" instead of a duplicated statement inside and
outside of the try/except block.

(From OE-Core rev: c92399c355d1333eff37ea799832a8890acd0d74)

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Yoann Congal
2025-08-06 17:55:49 +02:00
committed by Richard Purdie
parent b4eacbf7c1
commit 938abd7c30

View File

@@ -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