mirror of
https://github.com/tw93/Mole.git
synced 2026-02-06 20:05:37 +00:00
optimize code structure and reduce duplication
This commit is contained in:
BIN
bin/analyze-go
BIN
bin/analyze-go
Binary file not shown.
@@ -258,7 +258,7 @@ safe_clean() {
|
||||
for path in "${existing_paths[@]}"; do
|
||||
(
|
||||
local size
|
||||
size=$(du -sk "$path" 2> /dev/null | awk '{print $1}' || echo "0")
|
||||
size=$(get_path_size_kb "$path")
|
||||
local count
|
||||
count=$(find "$path" -type f 2> /dev/null | wc -l | tr -d ' ')
|
||||
# Use index + PID for unique filename
|
||||
@@ -317,7 +317,7 @@ safe_clean() {
|
||||
|
||||
for path in "${existing_paths[@]}"; do
|
||||
local size_bytes
|
||||
size_bytes=$(du -sk "$path" 2> /dev/null | awk '{print $1}' || echo "0")
|
||||
size_bytes=$(get_path_size_kb "$path")
|
||||
local count
|
||||
count=$(find "$path" -type f 2> /dev/null | wc -l | tr -d ' ')
|
||||
|
||||
@@ -718,7 +718,7 @@ perform_cleanup() {
|
||||
if is_orphaned "$bundle_id" "$match"; then
|
||||
# Use timeout to prevent du from hanging on large/problematic directories
|
||||
local size_kb
|
||||
size_kb=$(run_with_timeout 2 du -sk "$match" 2> /dev/null | awk '{print $1}' || echo "0")
|
||||
size_kb=$(run_with_timeout 2 get_path_size_kb "$match")
|
||||
if [[ -z "$size_kb" || "$size_kb" == "0" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -179,7 +179,7 @@ cleanup_path() {
|
||||
fi
|
||||
|
||||
local size_kb
|
||||
size_kb=$(du -sk "$expanded_path" 2> /dev/null | awk '{print $1}' || echo "0")
|
||||
size_kb=$(get_path_size_kb "$expanded_path")
|
||||
local size_display=""
|
||||
if [[ "$size_kb" =~ ^[0-9]+$ && "$size_kb" -gt 0 ]]; then
|
||||
size_display=$(bytes_to_human "$((size_kb * 1024))")
|
||||
|
||||
BIN
bin/status-go
BIN
bin/status-go
Binary file not shown.
@@ -217,8 +217,8 @@ scan_applications() {
|
||||
local app_size="N/A"
|
||||
local app_size_kb="0"
|
||||
if [[ -d "$app_path" ]]; then
|
||||
# Get size in KB, then format for display (single du call)
|
||||
app_size_kb=$(du -sk "$app_path" 2> /dev/null | awk '{print $1}' || echo "0")
|
||||
# Get size in KB, then format for display
|
||||
app_size_kb=$(get_path_size_kb "$app_path")
|
||||
app_size=$(bytes_to_human "$((app_size_kb * 1024))")
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user