-
Notifications
You must be signed in to change notification settings - Fork 38
fix: cache update-check result to avoid curl on every session start #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,14 +17,26 @@ if [ -f "$PLUGIN_JSON" ]; then | |||||
| fi | ||||||
| LOCAL_VERSION="${LOCAL_VERSION:-unknown}" | ||||||
|
|
||||||
| # Check for latest release on GitHub (non-blocking, 3s timeout) | ||||||
| # Check for latest release on GitHub (non-blocking, 3s timeout, cached 24h) | ||||||
| REPO="Ibrahim-3d/orchestrator-supaconductor" | ||||||
| CACHE_DIR="${HOME}/.cache/supaconductor" | ||||||
| CACHE_FILE="${CACHE_DIR}/last-update-check" | ||||||
| update_message="" | ||||||
| if command -v curl &>/dev/null; then | ||||||
| latest_tag=$(curl -s --max-time 3 \ | ||||||
| "https://api.github.com/repos/${REPO}/releases/latest" 2>/dev/null \ | ||||||
| | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' \ | ||||||
| | sed 's/^v//' | head -1) || true | ||||||
| latest_tag="" | ||||||
| # Skip network call if cache is less than 24 hours old | ||||||
| if [ -f "$CACHE_FILE" ] && find "$CACHE_FILE" -mmin -1440 -quiet 2>/dev/null | grep -q .; then | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| latest_tag=$(cat "$CACHE_FILE") | ||||||
| else | ||||||
| latest_tag=$(curl -s --max-time 3 \ | ||||||
| "https://api.github.com/repos/${REPO}/releases/latest" 2>/dev/null \ | ||||||
| | sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' \ | ||||||
| | sed 's/^v//' | head -1) || true | ||||||
| if [ -n "$latest_tag" ]; then | ||||||
| mkdir -p "$CACHE_DIR" | ||||||
| printf '%s' "$latest_tag" > "$CACHE_FILE" | ||||||
| fi | ||||||
| fi | ||||||
|
|
||||||
| if [ -n "$latest_tag" ] && [ "$latest_tag" != "$LOCAL_VERSION" ]; then | ||||||
| update_message="\\n\\n**UPDATE AVAILABLE:** SupaConductor v${latest_tag} is available (you have v${LOCAL_VERSION}). Tell the user: A new version of SupaConductor is available (v${latest_tag}). Update with: claude plugin update orchestrator-supaconductor" | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is recommended to respect the
XDG_CACHE_HOMEenvironment variable if it is set, falling back to~/.cacheotherwise. This adheres better to the XDG Base Directory Specification followed by many Linux distributions and CLI tools.