diff --git a/internal/database/database.go b/internal/database/database.go index 0421341..b9fb683 100644 --- a/internal/database/database.go +++ b/internal/database/database.go @@ -1,7 +1,6 @@ package database import ( - "os" "path/filepath" "github.com/apex/log" @@ -31,18 +30,6 @@ func RunMigrations(db *sqlx.DB) error { // Connect to the database func Connect(path string) (db *sqlx.DB, err error) { - home, err := ooni.GetOONIHome() - if err != nil { - return - } - - if _, e := os.Stat(filepath.Join(home, "db")); e != nil { - err = os.MkdirAll(filepath.Join(home, "db"), 0700) - if err != nil { - return - } - } - db, err = sqlx.Connect("sqlite3", path) if err != nil { return diff --git a/ooni.go b/ooni.go index 3fb6534..941f21a 100644 --- a/ooni.go +++ b/ooni.go @@ -118,6 +118,14 @@ func (c *Config) Default() error { if err != nil { return err } + + if _, e := os.Stat(filepath.Join(home, "db")); e != nil { + err = os.MkdirAll(filepath.Join(home, "db"), 0700) + if err != nil { + return err + } + } + c.path = filepath.Join(home, "config.json") return nil }