From e3eb98269e5c8d45b2c8dc804de0915c15dfac1e Mon Sep 17 00:00:00 2001 From: Ben Iofel Date: Mon, 23 Mar 2026 01:27:02 -0400 Subject: [PATCH] fix: prevent empty cache file from blocking usage data fetch The stampede lock `touch "$cache_file"` on line 215 creates a 0-byte file before fetching. If the fetch fails (network timeout, missing token, etc.), subsequent invocations within 60 seconds see a "fresh" empty cache and skip the fetch entirely, showing dashes instead of usage data. Adding `-s` (file exists and is non-empty) ensures that a 0-byte cache file left by a failed fetch is not treated as a valid cache hit. Co-Authored-By: Claude Opus 4.6 --- statusline.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/statusline.sh b/statusline.sh index cb5faa5..b6ce379 100755 --- a/statusline.sh +++ b/statusline.sh @@ -200,7 +200,7 @@ needs_refresh=true usage_data="" # Check cache — shared across all Claude Code instances to avoid rate limits -if [ -f "$cache_file" ]; then +if [ -f "$cache_file" ] && [ -s "$cache_file" ]; then cache_mtime=$(stat -c %Y "$cache_file" 2>/dev/null || stat -f %m "$cache_file" 2>/dev/null) now=$(date +%s) cache_age=$(( now - cache_mtime ))