Skip to content

Commit

Permalink
feat(xen): garbage collect loader/entries
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed Aug 25, 2024
1 parent 05ee9dc commit 8c0733a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rust/tool/systemd/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ impl Installer {

if self.broken_gens.is_empty() {
log::info!("Collecting garbage...");
// Only collect garbage in these two directories. This way, no files that do not belong to
// Only collect garbage in these directories. This way, no files that do not belong to
// the NixOS installation are deleted. Lanzatool takes full control over the esp/EFI/nixos
// directory and deletes ALL files that it doesn't know about. Dual- or multiboot setups
// that need files in this directory will NOT work.
self.gc_roots.collect_garbage(&self.esp_paths.nixos)?;
// The esp/EFI/Linux directory is assumed to be potentially shared with other distros.
// The esp/EFI/Linux and loader/entries directories are assumed to be potentially shared with other distros.
// Thus, only files that start with "nixos-" are garbage collected (i.e. potentially
// deleted).
self.gc_roots
Expand All @@ -113,6 +113,12 @@ impl Installer {
.and_then(|n| n.to_str())
.map_or(false, |n| n.starts_with("nixos-"))
})?;
self.gc_roots
.collect_garbage_with_filter(&self.esp_paths.entries, |p| {
p.file_name()
.and_then(|n| n.to_str())
.map_or(false, |n| n.starts_with("nixos-"))
})?;
} else {
// This might produce a ridiculous message if you have a lot of malformed generations.
let warning = indoc::formatdoc! {"
Expand Down

0 comments on commit 8c0733a

Please sign in to comment.