Fix daemon crash when backup/vc.db files exist
- Changed backup file filtering from checking file extension (.backup) to checking if filename contains '.backup' - This now properly filters files like 'beads.backup-pre-hash-20251030-171258.db' - Also exclude vc.db from database detection - Add strings import to beads.go - Improve error message to suggest manual removal Fixes bd-373c
This commit is contained in:
7
beads.go
7
beads.go
@@ -12,6 +12,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/steveyegge/beads/internal/configfile"
|
||||
"github.com/steveyegge/beads/internal/storage"
|
||||
@@ -198,12 +199,12 @@ func findDatabaseInTree() string {
|
||||
// Found .beads/ directory, look for *.db files
|
||||
matches, err := filepath.Glob(filepath.Join(beadsDir, "*.db"))
|
||||
if err == nil && len(matches) > 0 {
|
||||
// Filter out backup files
|
||||
// Filter out backup files and vc.db
|
||||
var validDBs []string
|
||||
for _, match := range matches {
|
||||
baseName := filepath.Base(match)
|
||||
// Skip backup files (e.g., beads.db.backup, bd.db.backup)
|
||||
if filepath.Ext(baseName) != ".backup" {
|
||||
// Skip backup files (contains ".backup" in name) and vc.db
|
||||
if !strings.Contains(baseName, ".backup") && baseName != "vc.db" {
|
||||
validDBs = append(validDBs, match)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user