1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 20:50:06 +00:00

fix: dedupe cleanup previews by filesystem identity

This commit is contained in:
Tw93
2026-03-19 00:32:28 +08:00
parent 03db800709
commit 821a824d81
5 changed files with 106 additions and 2 deletions

View File

@@ -117,6 +117,8 @@ project_cache_has_indicators() {
# Discover candidate project roots without scanning the whole home directory.
discover_project_cache_roots() {
local -a roots=()
local -a unique_roots=()
local -a seen_identities=()
local root
for root in "${MOLE_PURGE_DEFAULT_SEARCH_PATHS[@]}"; do
@@ -147,7 +149,18 @@ discover_project_cache_roots() {
[[ ${#roots[@]} -eq 0 ]] && return 0
printf '%s\n' "${roots[@]}" | LC_ALL=C sort -u
for root in "${roots[@]}"; do
local identity
identity=$(mole_path_identity "$root")
if [[ ${#seen_identities[@]} -gt 0 ]] && mole_identity_in_list "$identity" "${seen_identities[@]}"; then
continue
fi
seen_identities+=("$identity")
unique_roots+=("$root")
done
[[ ${#unique_roots[@]} -gt 0 ]] && printf '%s\n' "${unique_roots[@]}"
}
# Scan a project root for supported build caches while pruning heavy subtrees.