fix: invert FindAndOpenSQLiteStore existence check
The condition was backwards — it exited with "database already exists" when the file was found, and tried to open it when it did not exist. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -118,10 +118,7 @@ func (s *nodeServiceImpl) getPermContext() (*permContext, error) {
|
|||||||
}
|
}
|
||||||
for relType, pLevel := range permRelLevels {
|
for relType, pLevel := range permRelLevels {
|
||||||
for _, tgt := range node.Relations[string(relType)] {
|
for _, tgt := range node.Relations[string(relType)] {
|
||||||
eff := curr.level
|
eff := min(curr.level, pLevel)
|
||||||
if pLevel < eff {
|
|
||||||
eff = pLevel
|
|
||||||
}
|
|
||||||
if eff > pc.levels[tgt] {
|
if eff > pc.levels[tgt] {
|
||||||
queue = append(queue, entry{tgt, eff})
|
queue = append(queue, entry{tgt, eff})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ func InitSQLiteStore(path string) error {
|
|||||||
|
|
||||||
// FindAndOpenSQLiteStore opens the SQLite database. If the AX_DB_PATH environment
|
// FindAndOpenSQLiteStore opens the SQLite database. If the AX_DB_PATH environment
|
||||||
// variable is set, it uses that path directly. Otherwise, it walks up from the
|
// variable is set, it uses that path directly. Otherwise, it walks up from the
|
||||||
// current working directory to find an .ax.db file.
|
// current working directory to find an .ax/ax.db file.
|
||||||
func FindAndOpenSQLiteStore() (GraphStore, error) {
|
func FindAndOpenSQLiteStore() (GraphStore, error) {
|
||||||
if dbpath := os.Getenv("AX_DB_PATH"); dbpath != "" {
|
if dbpath := os.Getenv("AX_DB_PATH"); dbpath != "" {
|
||||||
return NewSQLiteStore(dbpath)
|
return NewSQLiteStore(dbpath)
|
||||||
@@ -68,13 +68,11 @@ func FindAndOpenSQLiteStore() (GraphStore, error) {
|
|||||||
|
|
||||||
dataRoot, err := FindDataRoot(".local", "share")
|
dataRoot, err := FindDataRoot(".local", "share")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "failed to find data dir:", err)
|
return nil, fmt.Errorf("failed to find data dir: %w", err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
dbPath := filepath.Join(dataRoot, "ax.db")
|
dbPath := filepath.Join(dataRoot, "ax.db")
|
||||||
if _, err := os.Stat(dbPath); err == nil {
|
if _, err := os.Stat(dbPath); err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "database already exists:", dbPath)
|
return nil, fmt.Errorf("no database found at %s: run 'ax init' first", dbPath)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
return NewSQLiteStore(dbPath)
|
return NewSQLiteStore(dbPath)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user