fix: Auto-export to JSONL now works correctly [fixes #23]

Fixed bug where PersistentPostRun was clearing isDirty flag before
calling flushToJSONL(), causing the flush to abort immediately.

The fix ensures flushToJSONL() handles the isDirty flag itself,
allowing the JSONL export to complete successfully.

Also added Arch Linux AUR installation instructions to README.

Changes:
- cmd/bd/main.go: Fixed PersistentPostRun flush logic
- README.md: Added Arch Linux (AUR) installation section
- .beads/bd.jsonl: Auto-exported issue bd-169 (init -q flag bug)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-10-14 12:35:48 -07:00
parent b74f57c087
commit ccdacf087b
3 changed files with 197 additions and 101 deletions

View File

@@ -102,11 +102,6 @@ var rootCmd = &cobra.Command{
}
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
// Signal that store is closing (prevents background flush from accessing closed store)
storeMutex.Lock()
storeActive = false
storeMutex.Unlock()
// Flush any pending changes before closing
flushMutex.Lock()
needsFlush := isDirty && autoFlushEnabled
@@ -116,7 +111,7 @@ var rootCmd = &cobra.Command{
flushTimer.Stop()
flushTimer = nil
}
isDirty = false
// Don't clear isDirty here - let flushToJSONL do it
}
flushMutex.Unlock()
@@ -125,6 +120,11 @@ var rootCmd = &cobra.Command{
flushToJSONL()
}
// Signal that store is closing (prevents background flush from accessing closed store)
storeMutex.Lock()
storeActive = false
storeMutex.Unlock()
if store != nil {
_ = store.Close()
}