From a1f22391e98916082f640e9948d57f3beb480dc1 Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Sat, 22 Mar 2025 14:41:54 +0000 Subject: [PATCH] fix: create file when data store file not found --- internal/storage/datastore.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/storage/datastore.go b/internal/storage/datastore.go index 6b8d5f0..cb3cbb3 100644 --- a/internal/storage/datastore.go +++ b/internal/storage/datastore.go @@ -24,7 +24,9 @@ func InitDataStore() *DataStore { file, err := os.Open("./data.json") if err != nil { 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 } slog.Error("Could not load data store file!", slog.Any("error", err)) @@ -38,7 +40,7 @@ func InitDataStore() *DataStore { return nil } - slog.Info("Loaded data store") + slog.Info("Data store loaded") return GlobalDataStore }