fix: disable default db name

This commit is contained in:
hexxa 2022-01-29 14:09:24 +08:00 committed by Hexxa
parent 00bbb12843
commit 39d644931c
3 changed files with 6 additions and 4 deletions

View file

@ -16,7 +16,6 @@ import (
var (
ErrBucketNotFound = errors.New("bucket not found")
DBName = "quickshare.db"
)
type BoltPvd struct {
@ -26,7 +25,7 @@ type BoltPvd struct {
}
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})
if err != nil {
panic(err)

View file

@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/ihexxa/quickshare/src/kvstore"
@ -225,7 +226,8 @@ func TestKVStoreProviders(t *testing.T) {
}
defer os.RemoveAll(rootPath)
store := boltdbpvd.New(rootPath, 1024)
dbPath := filepath.Join(rootPath, "quickshare.db")
store := boltdbpvd.New(dbPath, 1024)
defer store.Close()
kvstoreTest(store, t)
})

View file

@ -132,11 +132,12 @@ func initDeps(cfg gocfg.ICfg) *depidx.Deps {
opensLimit := cfg.GrabInt("Fs.OpensLimit")
openTTL := cfg.GrabInt("Fs.OpenTTL")
readerTTL := cfg.GrabInt("Server.WriteTimeout") / 1000 // millisecond -> second
dbPath := cfg.GrabString("Db.DbPath")
ider := simpleidgen.New()
filesystem := local.NewLocalFS(rootPath, 0660, opensLimit, openTTL, readerTTL, ider)
jwtEncDec := jwt.NewJWTEncDec(secret)
kv := boltdbpvd.New(rootPath, 1024)
kv := boltdbpvd.New(dbPath, 1024)
users, err := userstore.NewKVUserStore(kv)
if err != nil {
panic(fmt.Sprintf("fail to init user store: %s", err))