fix: allow to start filebrowser with an existing but empty DB
This commit is contained in:
parent
bafe9f0ad7
commit
3ab3bfee58
@ -214,6 +214,9 @@ func setupLog(logMethod string) {
|
||||
}
|
||||
|
||||
func quickSetup(flags *pflag.FlagSet, d pythonData) {
|
||||
|
||||
log.Println("Executing quick setup...")
|
||||
|
||||
set := &settings.Settings{
|
||||
Key: generateRandomBytes(64), // 256 bit
|
||||
Signup: false,
|
||||
|
||||
16
cmd/utils.go
16
cmd/utils.go
@ -67,7 +67,7 @@ func python(fn pythonFunc, cfg pythonConfig) cobraFunc {
|
||||
data := pythonData{hadDB: true}
|
||||
|
||||
path := getParam(cmd.Flags(), "database")
|
||||
_, err := os.Stat(path)
|
||||
fd, err := os.Stat(path)
|
||||
|
||||
if os.IsNotExist(err) {
|
||||
data.hadDB = false
|
||||
@ -75,10 +75,16 @@ func python(fn pythonFunc, cfg pythonConfig) cobraFunc {
|
||||
if !cfg.noDB && !cfg.allowNoDB {
|
||||
log.Fatal(path + " does not exist. Please run 'filebrowser config init' first.")
|
||||
}
|
||||
} else if err != nil {
|
||||
panic(err)
|
||||
} else if err == nil && cfg.noDB {
|
||||
log.Fatal(path + " already exists")
|
||||
} else if err == nil {
|
||||
if cfg.noDB {
|
||||
log.Fatal(path + " already exists")
|
||||
}
|
||||
if fd.Size() == 0 {
|
||||
log.Println("Database file is empty")
|
||||
data.hadDB = false
|
||||
}
|
||||
} else {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
db, err := storm.Open(path)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user