1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 20:54:50 +00:00

chore: auto format code

This commit is contained in:
Tw93
2026-01-04 09:52:09 +00:00
parent 3906c020fe
commit b044fa3e60
5 changed files with 54 additions and 57 deletions

View File

@@ -600,7 +600,7 @@ is_path_whitelisted() {
local check_pattern="${pattern%/}"
local has_glob="false"
case "$check_pattern" in
*\**|*\?*|*\[*)
*\** | *\?* | *\[*)
has_glob="true"
;;
esac

View File

@@ -106,18 +106,18 @@ safe_remove() {
if [[ -e "$path" ]]; then
local size_kb
size_kb=$(get_path_size_kb "$path" 2>/dev/null || echo "0")
size_kb=$(get_path_size_kb "$path" 2> /dev/null || echo "0")
if [[ "$size_kb" -gt 0 ]]; then
file_size=$(bytes_to_human "$((size_kb * 1024))")
fi
if [[ -f "$path" || -d "$path" ]] && ! [[ -L "$path" ]]; then
local mod_time
mod_time=$(stat -f%m "$path" 2>/dev/null || echo "0")
mod_time=$(stat -f%m "$path" 2> /dev/null || echo "0")
local now
now=$(date +%s 2>/dev/null || echo "0")
now=$(date +%s 2> /dev/null || echo "0")
if [[ "$mod_time" -gt 0 && "$now" -gt 0 ]]; then
file_age=$(( (now - mod_time) / 86400 ))
file_age=$(((now - mod_time) / 86400))
fi
fi
fi
@@ -183,20 +183,20 @@ safe_sudo_remove() {
local file_size=""
local file_age=""
if sudo test -e "$path" 2>/dev/null; then
if sudo test -e "$path" 2> /dev/null; then
local size_kb
size_kb=$(sudo du -sk "$path" 2>/dev/null | awk '{print $1}' || echo "0")
size_kb=$(sudo du -sk "$path" 2> /dev/null | awk '{print $1}' || echo "0")
if [[ "$size_kb" -gt 0 ]]; then
file_size=$(bytes_to_human "$((size_kb * 1024))")
fi
if sudo test -f "$path" 2>/dev/null || sudo test -d "$path" 2>/dev/null; then
if sudo test -f "$path" 2> /dev/null || sudo test -d "$path" 2> /dev/null; then
local mod_time
mod_time=$(sudo stat -f%m "$path" 2>/dev/null || echo "0")
mod_time=$(sudo stat -f%m "$path" 2> /dev/null || echo "0")
local now
now=$(date +%s 2>/dev/null || echo "0")
now=$(date +%s 2> /dev/null || echo "0")
if [[ "$mod_time" -gt 0 && "$now" -gt 0 ]]; then
file_age=$(( (now - mod_time) / 86400 ))
file_age=$(((now - mod_time) / 86400))
fi
fi
fi

View File

@@ -118,7 +118,7 @@ debug_operation_start() {
# Log detailed operation information
debug_operation_detail() {
local detail_type="$1" # e.g., "Method", "Target", "Expected Outcome"
local detail_type="$1" # e.g., "Method", "Target", "Expected Outcome"
local detail_value="$2"
if [[ "${MO_DEBUG:-}" == "1" ]]; then
@@ -132,7 +132,7 @@ debug_operation_detail() {
# Log individual file action with metadata
debug_file_action() {
local action="$1" # e.g., "Would remove", "Removing"
local action="$1" # e.g., "Would remove", "Removing"
local file_path="$2"
local file_size="${3:-}"
local file_age="${4:-}"
@@ -153,7 +153,7 @@ debug_file_action() {
# Log risk level for operations
debug_risk_level() {
local risk_level="$1" # LOW, MEDIUM, HIGH
local risk_level="$1" # LOW, MEDIUM, HIGH
local reason="$2"
if [[ "${MO_DEBUG:-}" == "1" ]]; then

View File

@@ -133,7 +133,7 @@ opt_cache_refresh() {
for target_path in "${cache_targets[@]}"; do
if [[ -e "$target_path" ]]; then
local size_kb
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")
local size_human="unknown"
if [[ "$size_kb" -gt 0 ]]; then
size_human=$(bytes_to_human "$((size_kb * 1024))")