Made database file configurable through ZEIT_DB

This commit is contained in:
マリウス 2020-10-15 00:35:46 +01:00
parent 2aafaf9501
commit a8f46b9c94
No known key found for this signature in database
GPG key ID: C228EF0A530AF06F

View file

@ -1,6 +1,7 @@
package z package z
import ( import (
"os"
"log" "log"
"errors" "errors"
"strings" "strings"
@ -14,7 +15,12 @@ type Database struct {
} }
func InitDatabase() (*Database, error) { func InitDatabase() (*Database, error) {
db, err := buntdb.Open(":memory:") // TODO: Replace with file dbfile, ok := os.LookupEnv("ZEIT_DB")
if ok == false || dbfile == "" {
return nil, errors.New("please `export ZEIT_DB` to the location the zeit database should be stored at")
}
db, err := buntdb.Open(dbfile)
if err != nil { if err != nil {
return nil, err return nil, err
} }