From a8f46b9c9451d7613229e729e7a95946b087fa27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Thu, 15 Oct 2020 00:35:46 +0100 Subject: [PATCH] Made database file configurable through ZEIT_DB --- z/database.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/z/database.go b/z/database.go index e4a0ca1..4cabf9c 100644 --- a/z/database.go +++ b/z/database.go @@ -1,6 +1,7 @@ package z import ( + "os" "log" "errors" "strings" @@ -14,7 +15,12 @@ type Database struct { } 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 { return nil, err }