fix(server): db folder is not created correctly

This commit is contained in:
hexxa 2022-05-14 11:10:43 +08:00 committed by Hexxa
parent 2e426bb1f1
commit cf30f8db60
3 changed files with 5 additions and 3 deletions

1
.gitignore vendored
View file

@ -17,3 +17,4 @@
# build # build
dist dist
tmp tmp
quickshare

View file

@ -78,7 +78,7 @@ func DefaultConfig() (string, error) {
func DefaultConfigStruct() *Config { func DefaultConfigStruct() *Config {
return &Config{ return &Config{
Fs: &FSConfig{ Fs: &FSConfig{
Root: "root", Root: "quickshare",
OpensLimit: 1024, OpensLimit: 1024,
OpenTTL: 60, // 1 min OpenTTL: 60, // 1 min
}, },

View file

@ -135,13 +135,14 @@ 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)
if err := filesystem.MkdirAll(dbPath); err != nil { dbPath := cfg.GrabString("Db.DbPath")
dbDir := filepath.Dir(dbPath)
if err := filesystem.MkdirAll(dbDir); err != nil {
panic(fmt.Sprintf("fail to create path for db: %s", err)) panic(fmt.Sprintf("fail to create path for db: %s", err))
} }