]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
cargo-update-recipe-crates: Properly close target file after writing
authorMartin Schwan <m.schwan@phytec.de>
Wed, 17 Dec 2025 13:06:44 +0000 (14:06 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 22 Jan 2026 14:21:52 +0000 (14:21 +0000)
In do_update_crates(), properly close the target_file after writing to
it using the "with" statement.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/cargo-update-recipe-crates.bbclass

index ffc658f0f15b3f867ae9f1c8254e75d688094654..47e845c8221143f2beecba07286e64f31bec1562 100644 (file)
@@ -72,7 +72,8 @@ for root, dirs, files in os.walk('${CARGO_LOCK_SRC_DIR}'):
                 crates += c
 if crates is None:
     raise ValueError("Unable to find any Cargo.lock in ${CARGO_LOCK_SRC_DIR}")
-open("${TARGET_FILE}", 'w').write(crates)
+with open("${TARGET_FILE}", 'w') as f:
+    f.write(crates)
 EOF
 
     bbnote "Successfully update crates inside '${TARGET_FILE}'"