From a3103d3e59bc7e9163d52fb50fd4bfd985c50bb8 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Tue, 25 Nov 2025 10:47:24 -0800 Subject: [PATCH] fix: update last_import_time when hash matches but mtime is newer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When JSONL mtime changes without content change (e.g., git pull, touch), the staleness check would repeatedly trigger but auto-import would skip due to hash match, creating an infinite loop of "Database out of sync" errors. Now we update last_import_time even when skipping import due to hash match, breaking the staleness loop. Fixes #378 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- internal/autoimport/autoimport.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/autoimport/autoimport.go b/internal/autoimport/autoimport.go index 7d74b71b..71d9f3d2 100644 --- a/internal/autoimport/autoimport.go +++ b/internal/autoimport/autoimport.go @@ -98,6 +98,12 @@ func AutoImportIfNewer(ctx context.Context, store storage.Storage, dbPath string if currentHash == lastHash { notify.Debugf("auto-import skipped, JSONL unchanged (hash match)") + // Update last_import_time to prevent repeated staleness warnings + // This handles the case where mtime changed but content didn't (e.g., git pull, touch) + importTime := time.Now().Format(time.RFC3339) + if err := store.SetMetadata(ctx, "last_import_time", importTime); err != nil { + notify.Warnf("failed to update last_import_time: %v", err) + } return nil }