mirror of
https://codeberg.org/icewind/haze.git
synced 2026-10-01 08:44:09 +02:00
fix(clean): Handle caches that are files like phpunit-cache
Signed-off-by: Louis Chmn <louis@chmn.me>
This commit is contained in:
parent
d4bb1b8fe3
commit
aa85bc7bce
1 changed files with 10 additions and 4 deletions
14
src/main.rs
14
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();
|
||||
remove_dir_all(&path).into_diagnostic().wrap_err_with(|| {
|
||||
format!("Failed to cleanup stray workdir: {}", path.display())
|
||||
})?;
|
||||
if path.is_dir() {
|
||||
remove_dir_all(&path).into_diagnostic().wrap_err_with(|| {
|
||||
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