Fix issues with persist flag; Use custom logger for badger

This commit is contained in:
Pijus Kamandulis
2025-04-03 23:48:20 +03:00
parent 28e3c0c3d8
commit 598f2837af
3 changed files with 36 additions and 2 deletions

View File

@@ -77,8 +77,13 @@ func (c *ServerConfig) PopulateCalculatedFields() {
logger.SetLogLevel(logger.LogLevelInfo)
}
if c.PersistDataFilePath != "" {
fileInfo, _ := os.Stat(c.PersistDataFilePath)
fileInfo, err := os.Stat(c.PersistDataFilePath)
if c.PersistDataFilePath != "" && !os.IsNotExist(err) {
if err != nil {
logger.ErrorLn("Failed to get file info for persist path:", err)
os.Exit(1)
}
if c.DataStore == DataStoreJson && fileInfo.IsDir() {
logger.ErrorLn("--Persist cannot be a directory when using json data store")
os.Exit(1)