fix: fix issue if filestore app states are empty

This commit is contained in:
2025-07-26 00:30:34 -07:00
parent 753d1c60ea
commit 4acfd33eae
+13
View File
@@ -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 {