1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-12 18:40:14 +00:00

Update version check

This commit is contained in:
Tw93
2025-12-01 20:25:37 +08:00
parent 04cffed5b5
commit 4e60b29def
2 changed files with 6 additions and 14 deletions

View File

@@ -933,7 +933,7 @@ update_via_homebrew() {
fi fi
# Clear version check cache # 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 return 0
} }

18
mole
View File

@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/core/common.sh" source "$SCRIPT_DIR/lib/core/common.sh"
# Version info # Version info
VERSION="1.11.10" VERSION="1.11.11"
MOLE_TAGLINE="can dig deep to clean your Mac." MOLE_TAGLINE="can dig deep to clean your Mac."
# Check if Touch ID is already configured # 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 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() { check_for_updates() {
local cache="$HOME/.cache/mole/version_check"
local msg_cache="$HOME/.cache/mole/update_message" local msg_cache="$HOME/.cache/mole/update_message"
local debug_log="$HOME/.cache/mole/update_check_debug" local debug_log="$HOME/.cache/mole/update_check_debug"
local ttl="${MO_UPDATE_CHECK_TTL:-3600}" mkdir -p "$(dirname "$msg_cache")" 2> /dev/null
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
# Background version check (save to file, don't output) # Background version check (save to file, don't output)
# Always check in background, display result from previous check
( (
local latest local latest
local check_method="github" local check_method="github"
@@ -90,7 +83,6 @@ check_for_updates() {
echo -n > "$msg_cache" echo -n > "$msg_cache"
[[ -n "${MO_UPDATE_DEBUG:-}" ]] && echo "$(date): No update needed ($check_method): $VERSION == $latest" >> "$debug_log" [[ -n "${MO_UPDATE_DEBUG:-}" ]] && echo "$(date): No update needed ($check_method): $VERSION == $latest" >> "$debug_log"
fi fi
touch "$cache" 2> /dev/null
) & ) &
disown 2> /dev/null || true disown 2> /dev/null || true
} }
@@ -334,7 +326,7 @@ update_mole() {
fi fi
rm -f "$tmp_installer" 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 # Remove Mole from system