mirror of
https://codeberg.org/icewind/haze.git
synced 2026-10-01 16:54:08 +02:00
Merge pull request 'fix(clean): Handle caches that are files like phpunit-cache' (#35) from artonge/haze:artonge/fix/properly_clean_file into main
Reviewed-on: https://codeberg.org/icewind/haze/pulls/35
This commit is contained in:
commit
ef61b160de
1 changed files with 10 additions and 4 deletions
10
src/main.rs
10
src/main.rs
|
|
@ -18,7 +18,7 @@ use bollard::Docker;
|
|||
use itertools::Itertools;
|
||||
use miette::{IntoDiagnostic, Report, Result, WrapErr};
|
||||
use std::env::{var, vars};
|
||||
use std::fs::{create_dir_all, remove_dir_all, write};
|
||||
use std::fs::{create_dir_all, remove_dir_all, remove_file, write};
|
||||
use std::io::stdout;
|
||||
use std::os::unix::process::CommandExt;
|
||||
use std::process::{Command, ExitCode};
|
||||
|
|
@ -91,9 +91,15 @@ async fn main() -> Result<ExitCode> {
|
|||
if let Some(id) = cache_dir.file_name().to_str() {
|
||||
if !retain.iter().any(|cloud| cloud.id == id) {
|
||||
let path = cache_dir.path();
|
||||
if path.is_dir() {
|
||||
remove_dir_all(&path).into_diagnostic().wrap_err_with(|| {
|
||||
format!("Failed to cleanup stray workdir: {}", path.display())
|
||||
format!("Failed to cleanup stray cache dir: {}", path.display())
|
||||
})?;
|
||||
} else {
|
||||
remove_file(&path).into_diagnostic().wrap_err_with(|| {
|
||||
format!("Failed to cleanup stray cache file: {}", path.display())
|
||||
})?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue