Skip to content

Commit

Permalink
Show total cleaned/to clean amount
Browse files Browse the repository at this point in the history
fixes holmgr#43
  • Loading branch information
birkenfeld committed Oct 22, 2020
1 parent ff90a1a commit 805a5d5
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ fn main() {

let dry_run = matches.is_present("dry-run");

let mut total_cleaned = 0;

// Default to current invocation path.
let path = match matches.value_of("path") {
Some(p) => PathBuf::from(p),
Expand Down Expand Up @@ -239,12 +241,17 @@ fn main() {
for project_path in &paths {
match remove_not_built_with(project_path, matches.value_of("toolchains"), dry_run) {
Ok(cleaned_amount) if dry_run => {
total_cleaned += cleaned_amount;
info!("Would clean: {}", format_bytes(cleaned_amount))
}
Ok(cleaned_amount) => info!("Cleaned {}", format_bytes(cleaned_amount)),
Ok(cleaned_amount) => {
total_cleaned += cleaned_amount;
info!("Cleaned {}", format_bytes(cleaned_amount))
}
Err(e) => error!("Failed to clean {:?}: {}", project_path, e),
};
}
info!("Total amount: {}", format_bytes(total_cleaned));

return;
}
Expand All @@ -265,24 +272,36 @@ fn main() {
for project_path in &paths {
match remove_older_until_fits(project_path, size, dry_run) {
Ok(cleaned_amount) if dry_run => {
total_cleaned += cleaned_amount;
info!("Would clean: {}", format_bytes(cleaned_amount))
}
Ok(cleaned_amount) => info!("Cleaned {}", format_bytes(cleaned_amount)),
Ok(cleaned_amount) => {
total_cleaned += cleaned_amount;
info!("Cleaned {}", format_bytes(cleaned_amount))
}
Err(e) => error!("Failed to clean {:?}: {}", project_path, e),
};
}

info!("Total amount: {}", format_bytes(total_cleaned));

return;
}

for project_path in &paths {
match remove_older_then(project_path, &keep_duration, dry_run) {
Ok(cleaned_amount) if dry_run => {
total_cleaned += cleaned_amount;
info!("Would clean: {}", format_bytes(cleaned_amount))
}
Ok(cleaned_amount) => info!("Cleaned {}", format_bytes(cleaned_amount)),
Ok(cleaned_amount) => {
total_cleaned += cleaned_amount;
info!("Cleaned {}", format_bytes(cleaned_amount))
}
Err(e) => error!("Failed to clean {:?}: {}", project_path, e),
};
}

info!("Total amount: {}", format_bytes(total_cleaned));
}
}

0 comments on commit 805a5d5

Please sign in to comment.