mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 18:30:08 +00:00
fix: dedupe cleanup previews by filesystem identity
This commit is contained in:
23
bin/clean.sh
23
bin/clean.sh
@@ -129,6 +129,7 @@ PROJECT_ARTIFACT_HINT_EXAMPLES=()
|
||||
PROJECT_ARTIFACT_HINT_ESTIMATED_KB=0
|
||||
PROJECT_ARTIFACT_HINT_ESTIMATE_SAMPLES=0
|
||||
PROJECT_ARTIFACT_HINT_ESTIMATE_PARTIAL=false
|
||||
declare -a DRY_RUN_SEEN_IDENTITIES=()
|
||||
|
||||
# shellcheck disable=SC2329
|
||||
note_activity() {
|
||||
@@ -137,6 +138,20 @@ note_activity() {
|
||||
fi
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2329
|
||||
register_dry_run_cleanup_target() {
|
||||
local path="$1"
|
||||
local identity
|
||||
identity=$(mole_path_identity "$path")
|
||||
|
||||
if [[ ${#DRY_RUN_SEEN_IDENTITIES[@]} -gt 0 ]] && mole_identity_in_list "$identity" "${DRY_RUN_SEEN_IDENTITIES[@]}"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
DRY_RUN_SEEN_IDENTITIES+=("$identity")
|
||||
return 0
|
||||
}
|
||||
|
||||
CLEANUP_DONE=false
|
||||
# shellcheck disable=SC2329
|
||||
cleanup() {
|
||||
@@ -380,7 +395,12 @@ safe_clean() {
|
||||
log_operation "clean" "SKIPPED" "$path" "whitelist"
|
||||
fi
|
||||
[[ "$skip" == "true" ]] && continue
|
||||
[[ -e "$path" ]] && existing_paths+=("$path")
|
||||
if [[ -e "$path" ]]; then
|
||||
if [[ "$DRY_RUN" == "true" ]]; then
|
||||
register_dry_run_cleanup_target "$path" || continue
|
||||
fi
|
||||
existing_paths+=("$path")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$show_scan_feedback" == "true" ]]; then
|
||||
@@ -705,6 +725,7 @@ start_cleanup() {
|
||||
# Set current command for operation logging
|
||||
export MOLE_CURRENT_COMMAND="clean"
|
||||
log_operation_session_start "clean"
|
||||
DRY_RUN_SEEN_IDENTITIES=()
|
||||
|
||||
if [[ -t 1 ]]; then
|
||||
printf '\033[2J\033[H'
|
||||
|
||||
Reference in New Issue
Block a user