fix: create file when data store file not found
This commit is contained in:
parent
8407a1258f
commit
a1f22391e9
1 changed files with 4 additions and 2 deletions
|
|
@ -24,7 +24,9 @@ func InitDataStore() *DataStore {
|
||||||
file, err := os.Open("./data.json")
|
file, err := os.Open("./data.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
slog.Warn("Data store file not found; creating new store")
|
slog.Warn("Data store file not found; creating new file")
|
||||||
|
|
||||||
|
GlobalDataStore.Save()
|
||||||
return GlobalDataStore
|
return GlobalDataStore
|
||||||
}
|
}
|
||||||
slog.Error("Could not load data store file!", slog.Any("error", err))
|
slog.Error("Could not load data store file!", slog.Any("error", err))
|
||||||
|
|
@ -38,7 +40,7 @@ func InitDataStore() *DataStore {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
slog.Info("Loaded data store")
|
slog.Info("Data store loaded")
|
||||||
return GlobalDataStore
|
return GlobalDataStore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue