Force dbPath to be relative to main executable

This commit is contained in:
Deluan 2020-01-10 22:03:22 -05:00 committed by Deluan Quintão
parent c9742181ff
commit 10221b5471

View File

@ -1,7 +1,10 @@
package db_storm
import (
"fmt"
"os"
"path"
"path/filepath"
"sync"
"github.com/asdine/storm"
@ -16,7 +19,12 @@ var (
func Db() *storm.DB {
once.Do(func() {
err := os.MkdirAll(conf.Sonic.DbPath, 0700)
if err != nil {
panic(err)
}
dbPath := path.Join(conf.Sonic.DbPath, "storm.db")
dbPath = fmt.Sprintf(".%c%s", filepath.Separator, dbPath)
instance, err := storm.Open(dbPath)
log.Debug("Opening Storm DB from: " + dbPath)
if err != nil {