From 128c3d0bbecff34877c60d54a1b6e8d61ae99ac7 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 27 Jun 2024 13:53:45 -0400 Subject: [PATCH] kargs: Minor code reordering No functional changes, but it's clearer to have the `remote_kargs` definition below where we do the short-circuit. Signed-off-by: Colin Walters --- lib/src/kargs.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/kargs.rs b/lib/src/kargs.rs index a05171f4d..ac1d12107 100644 --- a/lib/src/kargs.rs +++ b/lib/src/kargs.rs @@ -74,17 +74,19 @@ pub(crate) fn get_kargs( let existing_kargs: Vec = get_kargs_in_root(root, sys_arch)?; // Get the kargs in kargs.d of the pending image - let mut remote_kargs: Vec = vec![]; let (fetched_tree, _) = repo.read_commit(fetched.ostree_commit.as_str(), cancellable)?; let fetched_tree = fetched_tree.resolve_relative_path("/usr/lib/bootc/kargs.d"); let fetched_tree = fetched_tree .downcast::() .expect("downcast"); + // A special case: if there's no kargs.d directory in the pending (fetched) image, + // then we can just use the combined current kargs + if !fetched_tree.query_exists(cancellable) { - // if the kargs.d directory does not exist in the fetched image, return the existing kargs kargs.extend(existing_kargs); return Ok(kargs); } + + let mut remote_kargs: Vec = vec![]; let queryattrs = "standard::name,standard::type"; let queryflags = gio::FileQueryInfoFlags::NOFOLLOW_SYMLINKS; let fetched_iter = fetched_tree.enumerate_children(queryattrs, queryflags, cancellable)?;