Skip to content

Commit

Permalink
Add "tight" mode: remove junkfiles without actual autodeps resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
isbm committed Nov 3, 2023
1 parent 993899e commit dbee737
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/clidef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn cli(version: &'static str) -> Command {
.long("autodeps")
.default_value("none")
.value_name("mode")
.value_parser(["free", "clean", "none"])
.value_parser(["free", "clean", "tight", "none"])
.help(format!("Auto-add package dependencies.\n{}", " NOTE: This can increase the size, but might not always be useful\n".yellow()))
)
.arg(
Expand Down
7 changes: 6 additions & 1 deletion src/filters/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,16 @@ impl ResourcesDataFilter {

impl DataFilter for ResourcesDataFilter {
fn filter(&self, data: &mut HashSet<PathBuf>) {
if self.autodeps == Autodeps::Clean || self.autodeps == Autodeps::Tight {
log::info!("Automatically removing potential junk resources");
}

let mut out: Vec<PathBuf> = Vec::default();
for p in &self.data {
if self.filter_archives(p)
|| self.filter_images(p)
|| (self.autodeps == Autodeps::Clean && ResourcesDataFilter::is_potential_junk(p.to_str().unwrap()))
|| ((self.autodeps == Autodeps::Clean || self.autodeps == Autodeps::Tight)
&& ResourcesDataFilter::is_potential_junk(p.file_name().unwrap().to_str().unwrap()))
{
continue;
}
Expand Down
4 changes: 3 additions & 1 deletion src/procdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ use std::{
};

/// Autodependency mode
#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Autodeps {
Undef,
Free,
Clean,
Tight,
}
/// Main processing of profiles or other data
#[derive(Clone)]
Expand Down Expand Up @@ -52,6 +53,7 @@ impl TintProcessor {
match ad.as_str() {
"free" => self.autodeps = Autodeps::Free,
"clean" => self.autodeps = Autodeps::Clean,
"tight" => self.autodeps = Autodeps::Tight,
_ => self.autodeps = Autodeps::Undef,
}

Expand Down
2 changes: 1 addition & 1 deletion src/scanner/debpkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Scanner for DebPackageScanner {
}
}

if self.autodeps != Autodeps::Undef {
if self.autodeps == Autodeps::Clean || self.autodeps == Autodeps::Free {
// Trace dependencies graph for the package
for p in tracedeb::DebPackageTrace::new().trace(pkgname.to_owned()) {
log::info!("Keeping dependency package: {}", p.bright_yellow());
Expand Down

0 comments on commit dbee737

Please sign in to comment.