-
Notifications
You must be signed in to change notification settings - Fork 7.3k
fix(hooks): portable mtime in macOS hook throttles; doc cleanup #1811
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
Changes from 1 commit
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -161,8 +161,8 @@ fi | |||||
| # treating markers older than 1 hour as stale and reclaiming them. | ||||||
| PENDING_FILE="$MEMPAL_STATE_DIR/antigravity_pending_${CONVERSATION_ID}" | ||||||
| if [ -f "$PENDING_FILE" ]; then | ||||||
| # mtime in epoch seconds (date -r); if stale (> 1 hour), reclaim. | ||||||
| if mtime=$(date -r "$PENDING_FILE" '+%s' 2>/dev/null) \ | ||||||
| # mtime in epoch seconds (portable; BSD/macOS `date -r` takes epoch, not a path). | ||||||
| if mtime=$("$MEMPAL_PYTHON_BIN" -c "import os, sys; print(int(os.path.getmtime(sys.argv[1])))" "$PENDING_FILE" 2>/dev/null) \ | ||||||
|
Contributor
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. In bash, double quotes allow parameter expansion. The expression
Suggested change
|
||||||
| && now=$(date '+%s') \ | ||||||
| && [ -n "$mtime" ] \ | ||||||
| && [ "$((now - mtime))" -lt 3600 ]; then | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -388,7 +388,7 @@ mempal_gc_stale_state() { | |||||
| local marker="$MEMPAL_STATE_DIR/cursor_last_sweep" | ||||||
| if [ -f "$marker" ]; then | ||||||
| local mtime now | ||||||
| if mtime=$(date -r "$marker" '+%s' 2>/dev/null) \ | ||||||
| if mtime=$("$MEMPAL_PYTHON_BIN" -c "import os, sys; print(int(os.path.getmtime(sys.argv[1])))" "$marker" 2>/dev/null) \ | ||||||
|
Contributor
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. In bash, double quotes allow parameter expansion. The expression
Suggested change
|
||||||
| && now=$(date '+%s' 2>/dev/null) \ | ||||||
| && [ -n "$mtime" ] \ | ||||||
| && [ "$((now - mtime))" -lt 86400 ]; then | ||||||
|
|
||||||
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.
In bash, double quotes allow parameter expansion. The expression
sys.argv[1]contains$1, which is expanded by the shell to the first positional parameter of the current context (which is empty insidemempal_gc_stale_state). This results in a Python syntax error (sys.argv[]) and causes the check to silently fail. Escape the$as\$1to pass it literally to Python.