Skip to content

Commit

Permalink
Collect package names in totals for dry-run
Browse files Browse the repository at this point in the history
  • Loading branch information
isbm committed Nov 10, 2023
1 parent 379b978 commit a3502ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/scanner/dlst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
Data lister (fancy STDOUT printer)
*/

use crate::filters::resources;
use crate::{
filters::resources,
scanner::{debftrace::DebPkgFileTrace, traceitf::PkgFileTrace},
};
use bytesize::ByteSize;
use colored::Colorize;
use filesize::PathExt;
use std::{
collections::HashSet,
os::unix::prelude::PermissionsExt,
path::{Path, PathBuf},
};
Expand Down Expand Up @@ -110,6 +114,17 @@ impl<'a> ContentFormatter<'a> {
d_size += p.metadata().unwrap().len();
}

// Collect preserved packages
let mut pkgs: HashSet<String> = HashSet::default();
let mut pt = DebPkgFileTrace::new();
for p in self.fs_data {
if let Some(pkg) = pt.trace(p.clone()) {
pkgs.insert(pkg);
}
}
let mut pkgs = pkgs.into_iter().collect::<Vec<String>>();
pkgs.sort();

// Print the summary
println!(
"\nRemoved {} files, releasing {} of a disk space",
Expand All @@ -128,7 +143,7 @@ impl<'a> ContentFormatter<'a> {
ByteSize::b(j_size).to_string().bright_yellow()
);
}
println!("");
println!("Kept {} packages as follows:\n {}\n", pkgs.len().to_string().bright_yellow(), pkgs.join(", "));
}

/// Get dir/name split, painted accordingly
Expand Down
1 change: 1 addition & 0 deletions src/scanner/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod binlib;
pub mod debftrace;
pub mod debpkg;
pub(crate) mod dlst;
pub mod general;
Expand Down

0 comments on commit a3502ab

Please sign in to comment.