Force dbPath to be relative to main executable
This commit is contained in:
parent
c9742181ff
commit
10221b5471
1 changed files with 8 additions and 0 deletions
|
|
@ -1,7 +1,10 @@
|
||||||
package db_storm
|
package db_storm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/asdine/storm"
|
"github.com/asdine/storm"
|
||||||
|
|
@ -16,7 +19,12 @@ var (
|
||||||
|
|
||||||
func Db() *storm.DB {
|
func Db() *storm.DB {
|
||||||
once.Do(func() {
|
once.Do(func() {
|
||||||
|
err := os.MkdirAll(conf.Sonic.DbPath, 0700)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
dbPath := path.Join(conf.Sonic.DbPath, "storm.db")
|
dbPath := path.Join(conf.Sonic.DbPath, "storm.db")
|
||||||
|
dbPath = fmt.Sprintf(".%c%s", filepath.Separator, dbPath)
|
||||||
instance, err := storm.Open(dbPath)
|
instance, err := storm.Open(dbPath)
|
||||||
log.Debug("Opening Storm DB from: " + dbPath)
|
log.Debug("Opening Storm DB from: " + dbPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue