From aa85bc7bce7dde1940cf78aef46fd8b1c485380f Mon Sep 17 00:00:00 2001 From: Louis Chmn Date: Wed, 12 Aug 2026 18:16:27 +0200 Subject: [PATCH] fix(clean): Handle caches that are files like phpunit-cache Signed-off-by: Louis Chmn --- src/main.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5b2e945..11c74f9 100644 --- a/src/main.rs +++ b/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 { 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()) + })?; + } } } }