Skip to content

Commit fa1726b

Browse files
composefs/upgrade: Remove existing staged entries
When upgrading, switching if there is already a staged directory for bootloader entries, then delete it as we would overwrite it anyway Fixes: #1857 Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent d8ce931 commit fa1726b

File tree

1 file changed

+12
-4
lines changed
  • crates/lib/src/bootc_composefs

1 file changed

+12
-4
lines changed

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,19 @@ pub(crate) fn setup_composefs_bls_boot(
730730
let mut booted_bls = get_booted_bls(&boot_dir)?;
731731
booted_bls.sort_key = Some(secondary_sort_key(&os_id));
732732

733+
let staged_path = loader_path.join(STAGED_BOOT_LOADER_ENTRIES);
734+
735+
// Delete the staged entries directory if it exists as we want to overwrite the entries
736+
// anyway
737+
if boot_dir
738+
.remove_all_optional(TYPE1_ENT_PATH_STAGED)
739+
.context("Failed to remove staged directory")?
740+
{
741+
tracing::debug!("Removed existing staged entries directory");
742+
}
743+
733744
// This will be atomically renamed to 'loader/entries' on shutdown/reboot
734-
(
735-
loader_path.join(STAGED_BOOT_LOADER_ENTRIES),
736-
Some(booted_bls),
737-
)
745+
(staged_path, Some(booted_bls))
738746
} else {
739747
(loader_path.join(BOOT_LOADER_ENTRIES), None)
740748
};

0 commit comments

Comments
 (0)