aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/commands
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-05 13:12:56 +0900
committernsfisis <nsfisis@gmail.com>2026-05-05 13:12:56 +0900
commita10adb3b9ff3e1fe7ae0b8dc6440f171dde5f0ab (patch)
tree5dde666652768c4cbf3294e2ce17d78daa18b0c2 /crates/mozart/src/commands
parent78a627f9b839e902faec6e5f7fee4ec19fc0e4b8 (diff)
downloadphp-mozart-a10adb3b9ff3e1fe7ae0b8dc6440f171dde5f0ab.tar.gz
php-mozart-a10adb3b9ff3e1fe7ae0b8dc6440f171dde5f0ab.tar.zst
php-mozart-a10adb3b9ff3e1fe7ae0b8dc6440f171dde5f0ab.zip
feat(cache): include cache-vcs-dir in clear-cache command
Composer's clear-cache deletes cache-vcs-dir alongside repo/files caches, and GCs it via gcVcsCache (TTL-based, top-level subdir deletion, no size cap). Mozart was silently leaving VCS mirrors on disk forever — every clear-cache run grew the cache monotonically. Add cache_vcs_dir to CacheConfig (default {cache-dir}/vcs, env override COMPOSER_CACHE_VCS_DIR), wire it into clear-cache, and add Cache::gc_vcs mirroring Composer's gcVcsCache semantics.
Diffstat (limited to 'crates/mozart/src/commands')
-rw-r--r--crates/mozart/src/commands/clear_cache.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/crates/mozart/src/commands/clear_cache.rs b/crates/mozart/src/commands/clear_cache.rs
index d3acc28..b9a9303 100644
--- a/crates/mozart/src/commands/clear_cache.rs
+++ b/crates/mozart/src/commands/clear_cache.rs
@@ -18,6 +18,7 @@ pub async fn execute(
// Build the list of (key, path) pairs to process.
// cache-dir is only included in full clear mode, not GC mode.
let mut cache_paths: Vec<(&str, &std::path::PathBuf)> = vec![
+ ("cache-vcs-dir", &config.cache_vcs_dir),
("cache-repo-dir", &config.cache_repo_dir),
("cache-files-dir", &config.cache_files_dir),
];
@@ -47,11 +48,11 @@ pub async fn execute(
path.display()
));
let cache = Cache::new((*path).clone(), !config.no_cache);
- let result = if *key == "cache-files-dir" {
- cache.gc(config.cache_files_ttl, config.cache_files_maxsize)
- } else {
+ let result = match *key {
+ "cache-files-dir" => cache.gc(config.cache_files_ttl, config.cache_files_maxsize),
+ "cache-vcs-dir" => cache.gc_vcs(config.cache_ttl),
// cache-repo-dir: 1 GB cap (matches Composer)
- cache.gc(config.cache_ttl, 1024 * 1024 * 1024)
+ _ => cache.gc(config.cache_ttl, 1024 * 1024 * 1024),
};
if let Err(e) = result {
console.error(&format!("Error during GC of {key}: {e}"));
@@ -64,9 +65,10 @@ pub async fn execute(
for entry in std::fs::read_dir(path)? {
let entry = entry?;
let entry_path = entry.path();
- // Skip repo/files subdirs (cleared by their own iterations)
+ // Skip repo/files/vcs subdirs (cleared by their own iterations)
if entry_path == config.cache_files_dir
|| entry_path == config.cache_repo_dir
+ || entry_path == config.cache_vcs_dir
{
continue;
}