mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 19:50:04 +00:00
Safety reinforcement
This commit is contained in:
@@ -273,7 +273,7 @@ safe_clean() {
|
||||
local size
|
||||
size=$(get_path_size_kb "$path")
|
||||
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
|
||||
local tmp_file="$temp_dir/result_${idx}.$$"
|
||||
echo "$size $count" > "$tmp_file"
|
||||
@@ -332,7 +332,7 @@ safe_clean() {
|
||||
local size_bytes
|
||||
size_bytes=$(get_path_size_kb "$path")
|
||||
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 [[ "$DRY_RUN" != "true" ]]; then
|
||||
|
||||
@@ -241,7 +241,7 @@ safe_find_delete() {
|
||||
fi
|
||||
|
||||
# Execute find with safety limits
|
||||
find -- "$base_dir" \
|
||||
find "$base_dir" \
|
||||
-maxdepth 3 \
|
||||
-name "$pattern" \
|
||||
-type "$type_filter" \
|
||||
@@ -277,7 +277,7 @@ safe_sudo_find_delete() {
|
||||
fi
|
||||
|
||||
# Execute find with safety limits
|
||||
sudo find -- "$base_dir" \
|
||||
sudo find "$base_dir" \
|
||||
-maxdepth 3 \
|
||||
-name "$pattern" \
|
||||
-type "$type_filter" \
|
||||
@@ -1150,7 +1150,7 @@ clean_tool_cache() {
|
||||
get_path_size_kb() {
|
||||
local path="$1"
|
||||
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}"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user