diff --git a/bin/menutube.5s.sh b/bin/menutube.5s.sh index 3c042a7..51fdf36 100755 --- a/bin/menutube.5s.sh +++ b/bin/menutube.5s.sh @@ -238,7 +238,7 @@ release_tag_norm() { latest_release_tag_from_asset_url() { local tag tag="$(printf '%s' "$MENUTUBE_RELEASE_ASSET_URL" | /usr/bin/sed -n 's#.*releases/download/\([^/]*\)/.*#\1#p' | head -1)" - [[ -n "$tag" ]] || return 1 + [[ -n "$tag" && "$tag" != "latest" ]] || return 1 printf '%s' "$tag" } @@ -318,18 +318,23 @@ release_check_cache_age() { maybe_refresh_release_check() { truthy "$MENUTUBE_CHECK_RELEASE_UPDATES" || return [[ "$MENUTUBE_RELEASE_CHECK_TTL_SECONDS" == <-> ]] || MENUTUBE_RELEASE_CHECK_TTL_SECONDS=86400 - local age now lock_age + local age lock_file lock_mtime current_mtime now lock_age age="$(release_check_cache_age)" if [[ -n "$age" && "$age" -le "$MENUTUBE_RELEASE_CHECK_TTL_SECONDS" ]]; then return fi - now="$(date +%s 2>/dev/null || printf '0')" - lock_age="$(cache_mtime "${MENUTUBE_RELEASE_CHECK_CACHE}.lock")" - if [[ -n "$lock_age" && $(( now - lock_age )) -lt 120 ]]; then - return - fi mkdir -p "${MENUTUBE_RELEASE_CHECK_CACHE:h}" 2>/dev/null || return - : > "${MENUTUBE_RELEASE_CHECK_CACHE}.lock" 2>/dev/null || return + lock_file="${MENUTUBE_RELEASE_CHECK_CACHE}.lock" + lock_mtime="$(cache_mtime "$lock_file")" + if [[ -n "$lock_mtime" ]]; then + now="$(date +%s 2>/dev/null || printf '0')" + lock_age=$(( now - lock_mtime )) + if [[ "$lock_age" -gt 300 ]]; then + current_mtime="$(cache_mtime "$lock_file")" + [[ "$current_mtime" == "$lock_mtime" ]] && rm -f "$lock_file" 2>/dev/null || true + fi + fi + ( set -C; : > "$lock_file" ) 2>/dev/null || return "$SCRIPT" check-release >/dev/null 2>&1 & }