1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-15 21:00:05 +00:00

Safety reinforcement

This commit is contained in:
Tw93
2025-12-03 21:20:28 +08:00
parent 53bec36ebf
commit 54bbbcce47
3 changed files with 6 additions and 6 deletions

View File

@@ -273,7 +273,7 @@ safe_clean() {
local size local size
size=$(get_path_size_kb "$path") size=$(get_path_size_kb "$path")
local count local count
count=$(find -- "$path" -type f 2> /dev/null | wc -l | tr -d ' ') count=$(find "$path" -type f 2> /dev/null | wc -l | tr -d ' ')
# Use index + PID for unique filename # Use index + PID for unique filename
local tmp_file="$temp_dir/result_${idx}.$$" local tmp_file="$temp_dir/result_${idx}.$$"
echo "$size $count" > "$tmp_file" echo "$size $count" > "$tmp_file"
@@ -332,7 +332,7 @@ safe_clean() {
local size_bytes local size_bytes
size_bytes=$(get_path_size_kb "$path") size_bytes=$(get_path_size_kb "$path")
local count local count
count=$(find -- "$path" -type f 2> /dev/null | wc -l | tr -d ' ') count=$(find "$path" -type f 2> /dev/null | wc -l | tr -d ' ')
if [[ "$count" -gt 0 && "$size_bytes" -gt 0 ]]; then if [[ "$count" -gt 0 && "$size_bytes" -gt 0 ]]; then
if [[ "$DRY_RUN" != "true" ]]; then if [[ "$DRY_RUN" != "true" ]]; then

View File

@@ -241,7 +241,7 @@ safe_find_delete() {
fi fi
# Execute find with safety limits # Execute find with safety limits
find -- "$base_dir" \ find "$base_dir" \
-maxdepth 3 \ -maxdepth 3 \
-name "$pattern" \ -name "$pattern" \
-type "$type_filter" \ -type "$type_filter" \
@@ -277,7 +277,7 @@ safe_sudo_find_delete() {
fi fi
# Execute find with safety limits # Execute find with safety limits
sudo find -- "$base_dir" \ sudo find "$base_dir" \
-maxdepth 3 \ -maxdepth 3 \
-name "$pattern" \ -name "$pattern" \
-type "$type_filter" \ -type "$type_filter" \
@@ -1150,7 +1150,7 @@ clean_tool_cache() {
get_path_size_kb() { get_path_size_kb() {
local path="$1" local path="$1"
local result local result
result=$(du -sk -- "$path" 2> /dev/null | awk '{print $1}') result=$(du -sk "$path" 2> /dev/null | awk '{print $1}')
echo "${result:-0}" echo "${result:-0}"
} }

2
mole
View File

@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/core/common.sh" source "$SCRIPT_DIR/lib/core/common.sh"
# Version info # Version info
VERSION="1.11.18" VERSION="1.11.19"
MOLE_TAGLINE="can dig deep to clean your Mac." MOLE_TAGLINE="can dig deep to clean your Mac."
# Check if Touch ID is already configured # Check if Touch ID is already configured