mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 20:15:07 +00:00
fix(clean/uninstall): harden external cleanup accounting and relative app symlink resolution
This commit is contained in:
@@ -485,7 +485,9 @@ scan_applications() {
|
|||||||
local resolved_target="$link_target"
|
local resolved_target="$link_target"
|
||||||
if [[ "$link_target" != /* ]]; then
|
if [[ "$link_target" != /* ]]; then
|
||||||
local link_dir="${app_path%/*}"
|
local link_dir="${app_path%/*}"
|
||||||
resolved_target=$(cd "$link_dir" 2> /dev/null && cd "${link_target%/*}" 2> /dev/null && pwd)/"${link_target##*/}" 2> /dev/null || echo ""
|
local _link_parent="${link_target%/*}"
|
||||||
|
[[ "$_link_parent" == "$link_target" ]] && _link_parent="."
|
||||||
|
resolved_target=$(cd "$link_dir" 2> /dev/null && cd "$_link_parent" 2> /dev/null && pwd)/"${link_target##*/}" 2> /dev/null || echo ""
|
||||||
fi
|
fi
|
||||||
case "$resolved_target" in
|
case "$resolved_target" in
|
||||||
/System/* | /usr/bin/* | /usr/lib/* | /bin/* | /sbin/* | /private/etc/*)
|
/System/* | /usr/bin/* | /usr/lib/* | /bin/* | /sbin/* | /private/etc/*)
|
||||||
|
|||||||
@@ -916,11 +916,14 @@ clean_external_volume_target() {
|
|||||||
size_kb=$(get_path_size_kb "$target_path" 2> /dev/null || echo "0")
|
size_kb=$(get_path_size_kb "$target_path" 2> /dev/null || echo "0")
|
||||||
[[ "$size_kb" =~ ^[0-9]+$ ]] || size_kb=0
|
[[ "$size_kb" =~ ^[0-9]+$ ]] || size_kb=0
|
||||||
|
|
||||||
|
if [[ "$DRY_RUN" == "true" ]]; then
|
||||||
|
found_any=true
|
||||||
|
cleaned_count=$((cleaned_count + 1))
|
||||||
|
total_size=$((total_size + size_kb))
|
||||||
|
elif safe_remove "$target_path" true > /dev/null 2>&1; then
|
||||||
found_any=true
|
found_any=true
|
||||||
cleaned_count=$((cleaned_count + 1))
|
cleaned_count=$((cleaned_count + 1))
|
||||||
total_size=$((total_size + size_kb))
|
total_size=$((total_size + size_kb))
|
||||||
if [[ "$DRY_RUN" != "true" ]]; then
|
|
||||||
safe_remove "$target_path" true > /dev/null 2>&1 || true
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -938,11 +941,14 @@ clean_external_volume_target() {
|
|||||||
size_kb=$(get_path_size_kb "$metadata_file" 2> /dev/null || echo "0")
|
size_kb=$(get_path_size_kb "$metadata_file" 2> /dev/null || echo "0")
|
||||||
[[ "$size_kb" =~ ^[0-9]+$ ]] || size_kb=0
|
[[ "$size_kb" =~ ^[0-9]+$ ]] || size_kb=0
|
||||||
|
|
||||||
|
if [[ "$DRY_RUN" == "true" ]]; then
|
||||||
|
found_any=true
|
||||||
|
cleaned_count=$((cleaned_count + 1))
|
||||||
|
total_size=$((total_size + size_kb))
|
||||||
|
elif safe_remove "$metadata_file" true > /dev/null 2>&1; then
|
||||||
found_any=true
|
found_any=true
|
||||||
cleaned_count=$((cleaned_count + 1))
|
cleaned_count=$((cleaned_count + 1))
|
||||||
total_size=$((total_size + size_kb))
|
total_size=$((total_size + size_kb))
|
||||||
if [[ "$DRY_RUN" != "true" ]]; then
|
|
||||||
safe_remove "$metadata_file" true > /dev/null 2>&1 || true
|
|
||||||
fi
|
fi
|
||||||
done < <(command find "$volume" -type f -name "._*" -print0 2> /dev/null || true)
|
done < <(command find "$volume" -type f -name "._*" -print0 2> /dev/null || true)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user