]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
runqemu: refactor a duplicated cleanup statement
authorYoann Congal <yoann.congal@smile.fr>
Wed, 6 Aug 2025 15:55:49 +0000 (17:55 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 7 Aug 2025 09:43:42 +0000 (10:43 +0100)
Refactor using a "finally:" instead of a duplicated statement inside and
outside of the try/except block.

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/runqemu

index 4fb85177e3144f960e84dd3a8dfa62541b4776bb..3a339acc2a473bb4399f4f8d73ff66cf85d18d05 100755 (executable)
@@ -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