chore: pass datadir to db

This commit is contained in:
Kujtim Hoxha
2025-07-05 17:29:16 +02:00
parent fc065de4b4
commit 2a0f007d41
2 changed files with 3 additions and 6 deletions

View File

@@ -76,7 +76,7 @@ to assist developers in writing, debugging, and understanding code directly from
cwd = c
}
_, err := config.Init(cwd, debug)
cfg, err := config.Init(cwd, debug)
if err != nil {
return err
}
@@ -86,7 +86,7 @@ to assist developers in writing, debugging, and understanding code directly from
defer cancel()
// Connect DB, this will also run migrations
conn, err := db.Connect(ctx)
conn, err := db.Connect(ctx, cfg.Options.DataDirectory)
if err != nil {
return err
}

View File

@@ -11,13 +11,10 @@ import (
_ "github.com/ncruces/go-sqlite3/driver"
_ "github.com/ncruces/go-sqlite3/embed"
"github.com/charmbracelet/crush/internal/config"
"github.com/pressly/goose/v3"
)
func Connect(ctx context.Context) (*sql.DB, error) {
dataDir := config.Get().Options.DataDirectory
func Connect(ctx context.Context, dataDir string) (*sql.DB, error) {
if dataDir == "" {
return nil, fmt.Errorf("data.dir is not set")
}