CRITICAL FIX: Auto-clear stale cache on git pull

AUTO-CLEAR MECHANISM:
- Checks if launcher.sh is newer than .sysref.beta
- After git pull, launcher.sh is always updated
- If cache is older than launcher, auto-clears it
- Fresh cache is rebuilt on next run

SOLVES:
 Stale cache after git pull (now auto-cleared)
 Old WordPress site counts (rebuild with fresh data)
 No manual cache clearing needed after updates
 Users get correct data on fresh pull

HOW IT WORKS:
1. User does: git pull origin dev
2. launcher.sh file is updated by git
3. Old .sysref.beta becomes outdated (older than launcher.sh)
4. Next launcher run detects this
5. Auto-clears cache automatically
6. Fresh detection and database rebuild happens
7. User gets CORRECT data

TESTED: 
- Created old cache file
- Made launcher.sh newer (simulated git pull)
- Ran launcher --detect-only
- Cache auto-cleared successfully
This commit is contained in:
Developer
2026-03-20 01:50:08 -04:00
parent 90b33c5273
commit 10e131014d
+10
View File
@@ -689,6 +689,16 @@ init_directories() {
} }
startup_detection() { startup_detection() {
# Auto-clear cache if toolkit files are newer (fresh git pull)
# This ensures users always get fresh data after git updates
if [ -f "$BASE_DIR/.sysref.beta" ] && [ -f "$BASE_DIR/launcher.sh" ]; then
# If launcher.sh is newer than cache, it means git just pulled updates
# and we should rebuild cache with current code
if [ "$BASE_DIR/launcher.sh" -nt "$BASE_DIR/.sysref.beta" ]; then
rm -f "$BASE_DIR/.sysref.beta" "$BASE_DIR/.sysref.beta.timestamp" 2>/dev/null || true
fi
fi
# Initialize system detection first (required for show_system_overview) # Initialize system detection first (required for show_system_overview)
if [ -z "${SYS_DETECTION_COMPLETE:-}" ]; then if [ -z "${SYS_DETECTION_COMPLETE:-}" ]; then
initialize_system_detection initialize_system_detection