From a3502abeeed97e1800ff5b47dbcfc1819394b8d2 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Fri, 10 Nov 2023 18:50:44 +0100 Subject: [PATCH] Collect package names in totals for dry-run --- src/scanner/dlst.rs | 19 +++++++++++++++++-- src/scanner/mod.rs | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/scanner/dlst.rs b/src/scanner/dlst.rs index 0735277..7f0c038 100644 --- a/src/scanner/dlst.rs +++ b/src/scanner/dlst.rs @@ -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}, }; @@ -110,6 +114,17 @@ impl<'a> ContentFormatter<'a> { d_size += p.metadata().unwrap().len(); } + // Collect preserved packages + let mut pkgs: HashSet = 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::>(); + pkgs.sort(); + // Print the summary println!( "\nRemoved {} files, releasing {} of a disk space", @@ -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 diff --git a/src/scanner/mod.rs b/src/scanner/mod.rs index d25cc80..b8f1c6a 100644 --- a/src/scanner/mod.rs +++ b/src/scanner/mod.rs @@ -1,4 +1,5 @@ pub mod binlib; +pub mod debftrace; pub mod debpkg; pub(crate) mod dlst; pub mod general;