mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 17:00:17 +00:00
🐛 Optimize uninstallation of mole
This commit is contained in:
@@ -27,6 +27,15 @@ readonly LOG_MAX_SIZE_DEFAULT=1048576 # 1MB
|
|||||||
# Ensure log directory exists
|
# Ensure log directory exists
|
||||||
mkdir -p "$(dirname "$LOG_FILE")" 2>/dev/null || true
|
mkdir -p "$(dirname "$LOG_FILE")" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Log file maintenance (must be defined before logging functions)
|
||||||
|
rotate_log() {
|
||||||
|
local max_size="${MOLE_MAX_LOG_SIZE:-$LOG_MAX_SIZE_DEFAULT}"
|
||||||
|
if [[ -f "$LOG_FILE" ]] && [[ $(stat -f%z "$LOG_FILE" 2>/dev/null || echo 0) -gt "$max_size" ]]; then
|
||||||
|
mv "$LOG_FILE" "${LOG_FILE}.old" 2>/dev/null || true
|
||||||
|
touch "$LOG_FILE" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Enhanced logging functions with file logging support
|
# Enhanced logging functions with file logging support
|
||||||
log_info() {
|
log_info() {
|
||||||
rotate_log
|
rotate_log
|
||||||
@@ -58,15 +67,6 @@ log_header() {
|
|||||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] SECTION: $1" >> "$LOG_FILE" 2>/dev/null || true
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] SECTION: $1" >> "$LOG_FILE" 2>/dev/null || true
|
||||||
}
|
}
|
||||||
|
|
||||||
# Log file maintenance
|
|
||||||
rotate_log() {
|
|
||||||
local max_size="${MOLE_MAX_LOG_SIZE:-$LOG_MAX_SIZE_DEFAULT}"
|
|
||||||
if [[ -f "$LOG_FILE" ]] && [[ $(stat -f%z "$LOG_FILE" 2>/dev/null || echo 0) -gt "$max_size" ]]; then
|
|
||||||
mv "$LOG_FILE" "${LOG_FILE}.old" 2>/dev/null || true
|
|
||||||
touch "$LOG_FILE" 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# System detection
|
# System detection
|
||||||
detect_architecture() {
|
detect_architecture() {
|
||||||
if [[ "$(uname -m)" == "arm64" ]]; then
|
if [[ "$(uname -m)" == "arm64" ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user