Fix: Ensure JSONL directory exists in findJSONLPath
Added os.MkdirAll(dbDir, 0755) to ensure the .beads directory exists before attempting to glob for JSONL files. This fixes a bug where findJSONLPath() would fail silently if the directory doesn't exist yet, which can happen during new database initialization. The fix: - Creates the directory with 0755 permissions if it doesn't exist - Handles errors gracefully by returning the default path - Subsequent write operations will still fail with clear errors if directory creation fails Closes bd-36 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -202,6 +202,13 @@ func findJSONLPath() string {
|
||||
// Get the directory containing the database
|
||||
dbDir := filepath.Dir(dbPath)
|
||||
|
||||
// Ensure the directory exists (important for new databases)
|
||||
if err := os.MkdirAll(dbDir, 0755); err != nil {
|
||||
// If we can't create the directory, return default path anyway
|
||||
// (the subsequent write will fail with a clearer error)
|
||||
return filepath.Join(dbDir, "issues.jsonl")
|
||||
}
|
||||
|
||||
// Look for existing .jsonl files in the .beads directory
|
||||
pattern := filepath.Join(dbDir, "*.jsonl")
|
||||
matches, err := filepath.Glob(pattern)
|
||||
|
||||
Reference in New Issue
Block a user