1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 17:55:08 +00:00

fix: move logs to ~/Library/Logs/mole, add system idle assets cleanup

- Move log files from ~/.config/mole/ to ~/Library/Logs/mole/ per
     macOS convention. Fixes #569.
   - Add safe_sudo_find_delete for /Library/Application Support/
     com.apple.idleassetsd/Customer/ screensaver videos. Closes #570.
   - Update tests to reflect new log file paths.
This commit is contained in:
Tw93
2026-03-15 11:38:18 +08:00
parent 398097162c
commit 7a0b4cf07e
4 changed files with 14 additions and 8 deletions

View File

@@ -427,6 +427,12 @@ clean_support_app_data() {
safe_find_delete "$idle_assets_dir" "*" "$support_age_days" "f" || true safe_find_delete "$idle_assets_dir" "*" "$support_age_days" "f" || true
fi fi
# Clean system-level idle/aerial screensaver videos (macOS re-downloads as needed).
local sys_idle_assets_dir="/Library/Application Support/com.apple.idleassetsd/Customer"
if sudo test -d "$sys_idle_assets_dir" 2> /dev/null; then
safe_sudo_find_delete "$sys_idle_assets_dir" "*" "$support_age_days" "f" || true
fi
# Clean old aerial wallpaper videos (can be large, safe to remove). # Clean old aerial wallpaper videos (can be large, safe to remove).
safe_clean ~/Library/Application\ Support/com.apple.wallpaper/aerials/videos/* "Aerial wallpaper videos" safe_clean ~/Library/Application\ Support/com.apple.wallpaper/aerials/videos/* "Aerial wallpaper videos"

View File

@@ -21,9 +21,9 @@ fi
# Logging Configuration # Logging Configuration
# ============================================================================ # ============================================================================
readonly LOG_FILE="${HOME}/.config/mole/mole.log" readonly LOG_FILE="${HOME}/Library/Logs/mole/mole.log"
readonly DEBUG_LOG_FILE="${HOME}/.config/mole/mole_debug_session.log" readonly DEBUG_LOG_FILE="${HOME}/Library/Logs/mole/mole_debug_session.log"
readonly OPERATIONS_LOG_FILE="${HOME}/.config/mole/operations.log" readonly OPERATIONS_LOG_FILE="${HOME}/Library/Logs/mole/operations.log"
readonly LOG_MAX_SIZE_DEFAULT=1048576 # 1MB readonly LOG_MAX_SIZE_DEFAULT=1048576 # 1MB
readonly OPLOG_MAX_SIZE_DEFAULT=5242880 # 5MB readonly OPLOG_MAX_SIZE_DEFAULT=5242880 # 5MB

View File

@@ -206,7 +206,7 @@ EOF
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
MOLE_OUTPUT="$output" MOLE_OUTPUT="$output"
DEBUG_LOG="$HOME/.config/mole/mole_debug_session.log" DEBUG_LOG="$HOME/Library/Logs/mole/mole_debug_session.log"
[ -f "$DEBUG_LOG" ] [ -f "$DEBUG_LOG" ]
run grep "Mole Debug Session" "$DEBUG_LOG" run grep "Mole Debug Session" "$DEBUG_LOG"
@@ -228,7 +228,7 @@ EOF
run env HOME="$HOME" TERM="xterm-256color" MOLE_TEST_MODE=1 MO_DEBUG=1 "$PROJECT_ROOT/mole" clean --dry-run run env HOME="$HOME" TERM="xterm-256color" MOLE_TEST_MODE=1 MO_DEBUG=1 "$PROJECT_ROOT/mole" clean --dry-run
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
DEBUG_LOG="$HOME/.config/mole/mole_debug_session.log" DEBUG_LOG="$HOME/Library/Logs/mole/mole_debug_session.log"
run grep "User:" "$DEBUG_LOG" run grep "User:" "$DEBUG_LOG"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]

View File

@@ -50,7 +50,7 @@ setup() {
stdout_output="$(HOME="$HOME" bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/core/common.sh'; log_info '$message'")" stdout_output="$(HOME="$HOME" bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/core/common.sh'; log_info '$message'")"
[[ "$stdout_output" == *"$message"* ]] [[ "$stdout_output" == *"$message"* ]]
local log_file="$HOME/.config/mole/mole.log" local log_file="$HOME/Library/Logs/mole/mole.log"
[[ -f "$log_file" ]] [[ -f "$log_file" ]]
grep -q "INFO: $message" "$log_file" grep -q "INFO: $message" "$log_file"
} }
@@ -64,13 +64,13 @@ setup() {
[[ -s "$stderr_file" ]] [[ -s "$stderr_file" ]]
grep -q "$message" "$stderr_file" grep -q "$message" "$stderr_file"
local log_file="$HOME/.config/mole/mole.log" local log_file="$HOME/Library/Logs/mole/mole.log"
[[ -f "$log_file" ]] [[ -f "$log_file" ]]
grep -q "ERROR: $message" "$log_file" grep -q "ERROR: $message" "$log_file"
} }
@test "rotate_log_once only checks log size once per session" { @test "rotate_log_once only checks log size once per session" {
local log_file="$HOME/.config/mole/mole.log" local log_file="$HOME/Library/Logs/mole/mole.log"
mkdir -p "$(dirname "$log_file")" mkdir -p "$(dirname "$log_file")"
dd if=/dev/zero of="$log_file" bs=1024 count=1100 2> /dev/null dd if=/dev/zero of="$log_file" bs=1024 count=1100 2> /dev/null