[meta-lts-mixins][scarthgap/rust][PATCH 03/35] cargo-update-recipe-crates: Properly close target file after writing
Scott Murray <[email protected]> Fri, 31 Jul 2026 07:32:33 -0400
| Newsgroups | org.yoctoproject.lists.yocto-patches |
|---|---|
| Message-ID | <f0cba7dcc24d81f9c1b3752dfd8fa5d92488c75a.1785496469.git.scott.murray@konsulko.com> |
From: Martin Schwan <[email protected]> In do_update_crates(), properly close the target_file after writing to it using the "with" statement. Signed-off-by: Martin Schwan <[email protected]> Signed-off-by: Mathieu Dubois-Briand <[email protected]> Signed-off-by: Ross Burton <[email protected]> Signed-off-by: Richard Purdie <[email protected]> (adapted from oe-core commit c48e7308c19a7f804c2383b68e5afcd1517a7162) Signed-off-by: Scott Murray <[email protected]> --- classes-recipe/cargo-update-recipe-crates.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classes-recipe/cargo-update-recipe-crates.bbclass b/classes-recipe/cargo-update-recipe-crates.bbclass index ffc658f..47e845c 100644 --- a/classes-recipe/cargo-update-recipe-crates.bbclass +++ b/classes-recipe/cargo-update-recipe-crates.bbclass @@ -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}'" -- 2.55.0