From 4acfd33eae2b9801d074059409ce5d85f287ecf1 Mon Sep 17 00:00:00 2001 From: haopengzhan Date: Sat, 26 Jul 2025 00:30:34 -0700 Subject: [PATCH] fix: fix issue if filestore app states are empty --- internal/driver/driver.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/driver/driver.go b/internal/driver/driver.go index 7f85aa1..a3d86c7 100644 --- a/internal/driver/driver.go +++ b/internal/driver/driver.go @@ -76,6 +76,19 @@ func (d *Driver) Run(ctx context.Context) error { // processChanges now takes and modifies the AppState directly. func (d *Driver) processChanges(appState *storage.AppState, scrapedBags map[string]crawler.Bag) (bool, []string) { var notifications []string + if appState == nil { + log.Println("⚠️ AppState is nil, initializing a new one.") + appState = &storage.AppState{ + Bags: make(map[string]crawler.Bag), + ChatIDs: make([]int64, 0), + } + } + + if appState.Bags == nil { + log.Println("⚠️ AppState.Bags is nil, initializing a new map.") + appState.Bags = make(map[string]crawler.Bag) + } + hasChanges := false for sku, newBag := range scrapedBags {