From 4e60b29defdb5f7ec176f7609122eac746d0c261 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Mon, 1 Dec 2025 20:25:37 +0800 Subject: [PATCH] Update version check --- lib/core/common.sh | 2 +- mole | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/core/common.sh b/lib/core/common.sh index 5ab1da1..9f9a5a0 100755 --- a/lib/core/common.sh +++ b/lib/core/common.sh @@ -933,7 +933,7 @@ update_via_homebrew() { fi # Clear version check cache - rm -f "$HOME/.cache/mole/version_check" "$HOME/.cache/mole/update_message" + rm -f "$HOME/.cache/mole/update_message" return 0 } diff --git a/mole b/mole index 2252738..fd80f80 100755 --- a/mole +++ b/mole @@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/lib/core/common.sh" # Version info -VERSION="1.11.10" +VERSION="1.11.11" MOLE_TAGLINE="can dig deep to clean your Mac." # Check if Touch ID is already configured @@ -54,21 +54,14 @@ is_homebrew_install() { command -v brew > /dev/null 2>&1 && brew list mole > /dev/null 2>&1 } -# Check for updates (non-blocking, cached) +# Check for updates (non-blocking, always check in background) check_for_updates() { - local cache="$HOME/.cache/mole/version_check" local msg_cache="$HOME/.cache/mole/update_message" local debug_log="$HOME/.cache/mole/update_check_debug" - local ttl="${MO_UPDATE_CHECK_TTL:-3600}" - mkdir -p "$(dirname "$cache")" 2> /dev/null - - # Skip if checked recently - if [[ -f "$cache" ]]; then - local age=$(($(date +%s) - $(stat -f%m "$cache" 2> /dev/null || echo 0))) - [[ $age -lt $ttl ]] && return - fi + mkdir -p "$(dirname "$msg_cache")" 2> /dev/null # Background version check (save to file, don't output) + # Always check in background, display result from previous check ( local latest local check_method="github" @@ -90,7 +83,6 @@ check_for_updates() { echo -n > "$msg_cache" [[ -n "${MO_UPDATE_DEBUG:-}" ]] && echo "$(date): No update needed ($check_method): $VERSION == $latest" >> "$debug_log" fi - touch "$cache" 2> /dev/null ) & disown 2> /dev/null || true } @@ -334,7 +326,7 @@ update_mole() { fi rm -f "$tmp_installer" - rm -f "$HOME/.cache/mole/version_check" "$HOME/.cache/mole/update_message" + rm -f "$HOME/.cache/mole/update_message" } # Remove Mole from system