Skip to content

Commit c00731c

Browse files
CopilotSenkjM
andcommitted
Fix database path resolution for admin commands
Co-authored-by: SenkjM <[email protected]>
1 parent a391cb2 commit c00731c

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ output/
1818
# Output of the go coverage tool, specifically when used with LiteIDE
1919
*.out
2020

21+
# Binary output
22+
openlist
23+
2124
# Dependency directories (remove the comment below to include it)
2225
# vendor/
2326
/bin/*

internal/bootstrap/db.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package bootstrap
33
import (
44
"fmt"
55
stdlog "log"
6+
"path/filepath"
67
"strings"
78
"time"
89

@@ -51,8 +52,12 @@ func InitDB() {
5152
if !(strings.HasSuffix(database.DBFile, ".db") && len(database.DBFile) > 3) {
5253
log.Fatalf("db name error.")
5354
}
55+
dbPath := database.DBFile
56+
if !filepath.IsAbs(dbPath) {
57+
dbPath = filepath.Join(flags.DataDir, dbPath)
58+
}
5459
dB, err = gorm.Open(sqlite.Open(fmt.Sprintf("%s?_journal=WAL&_vacuum=incremental",
55-
database.DBFile)), gormConfig)
60+
dbPath)), gormConfig)
5661
}
5762
case "mysql":
5863
{

openlist

-96.5 MB
Binary file not shown.

0 commit comments

Comments
 (0)