fix: disable default db name
This commit is contained in:
parent
00bbb12843
commit
39d644931c
3 changed files with 6 additions and 4 deletions
|
@ -16,7 +16,6 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrBucketNotFound = errors.New("bucket not found")
|
ErrBucketNotFound = errors.New("bucket not found")
|
||||||
DBName = "quickshare.db"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type BoltPvd struct {
|
type BoltPvd struct {
|
||||||
|
@ -26,7 +25,7 @@ type BoltPvd struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(dbPath string, maxStrLen int) *BoltPvd {
|
func New(dbPath string, maxStrLen int) *BoltPvd {
|
||||||
boltPath := path.Join(path.Clean(dbPath), DBName)
|
boltPath := path.Clean(dbPath)
|
||||||
db, err := bolt.Open(boltPath, 0600, &bolt.Options{Timeout: 1 * time.Second})
|
db, err := bolt.Open(boltPath, 0600, &bolt.Options{Timeout: 1 * time.Second})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ihexxa/quickshare/src/kvstore"
|
"github.com/ihexxa/quickshare/src/kvstore"
|
||||||
|
@ -225,7 +226,8 @@ func TestKVStoreProviders(t *testing.T) {
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(rootPath)
|
defer os.RemoveAll(rootPath)
|
||||||
|
|
||||||
store := boltdbpvd.New(rootPath, 1024)
|
dbPath := filepath.Join(rootPath, "quickshare.db")
|
||||||
|
store := boltdbpvd.New(dbPath, 1024)
|
||||||
defer store.Close()
|
defer store.Close()
|
||||||
kvstoreTest(store, t)
|
kvstoreTest(store, t)
|
||||||
})
|
})
|
||||||
|
|
|
@ -132,11 +132,12 @@ func initDeps(cfg gocfg.ICfg) *depidx.Deps {
|
||||||
opensLimit := cfg.GrabInt("Fs.OpensLimit")
|
opensLimit := cfg.GrabInt("Fs.OpensLimit")
|
||||||
openTTL := cfg.GrabInt("Fs.OpenTTL")
|
openTTL := cfg.GrabInt("Fs.OpenTTL")
|
||||||
readerTTL := cfg.GrabInt("Server.WriteTimeout") / 1000 // millisecond -> second
|
readerTTL := cfg.GrabInt("Server.WriteTimeout") / 1000 // millisecond -> second
|
||||||
|
dbPath := cfg.GrabString("Db.DbPath")
|
||||||
|
|
||||||
ider := simpleidgen.New()
|
ider := simpleidgen.New()
|
||||||
filesystem := local.NewLocalFS(rootPath, 0660, opensLimit, openTTL, readerTTL, ider)
|
filesystem := local.NewLocalFS(rootPath, 0660, opensLimit, openTTL, readerTTL, ider)
|
||||||
jwtEncDec := jwt.NewJWTEncDec(secret)
|
jwtEncDec := jwt.NewJWTEncDec(secret)
|
||||||
kv := boltdbpvd.New(rootPath, 1024)
|
kv := boltdbpvd.New(dbPath, 1024)
|
||||||
users, err := userstore.NewKVUserStore(kv)
|
users, err := userstore.NewKVUserStore(kv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("fail to init user store: %s", err))
|
panic(fmt.Sprintf("fail to init user store: %s", err))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue