1
0
Fork 0
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:
Robin Appelman 2026-08-13 02:39:44 +02:00
commit ef61b160de

View file

@ -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())
})?;
}
}
}
}