use std::path::Path;
use super::cache_size_index;
use super::history;
use super::paths;
pub(super) fn reclaim_project_cache(project_root: &Path) {
reclaim_project_cache_under(paths::cache_root().as_path(), project_root);
}
pub(super) fn reclaim_project_cache_under(cache_root: &Path, project_root: &Path) {
let project_dir = paths::project_dir_under(cache_root, project_root);
let bytes = history::project_dir_bytes(&project_dir);
if std::fs::remove_dir_all(&project_dir).is_ok() && bytes > 0 {
cache_size_index::adjust(cache_root, -i64::try_from(bytes).unwrap_or(i64::MAX));
}
}