1
0
Fork 0
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:
Louis Chmn 2026-08-12 18:16:27 +02:00
commit aa85bc7bce

View file

@ -18,7 +18,7 @@ use bollard::Docker;
use itertools::Itertools; use itertools::Itertools;
use miette::{IntoDiagnostic, Report, Result, WrapErr}; use miette::{IntoDiagnostic, Report, Result, WrapErr};
use std::env::{var, vars}; 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::io::stdout;
use std::os::unix::process::CommandExt; use std::os::unix::process::CommandExt;
use std::process::{Command, ExitCode}; 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 let Some(id) = cache_dir.file_name().to_str() {
if !retain.iter().any(|cloud| cloud.id == id) { if !retain.iter().any(|cloud| cloud.id == id) {
let path = cache_dir.path(); let path = cache_dir.path();
remove_dir_all(&path).into_diagnostic().wrap_err_with(|| { if path.is_dir() {
format!("Failed to cleanup stray workdir: {}", path.display()) 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())
})?;
}
} }
} }
} }