fix: fix issue if filestore app states are empty
This commit is contained in:
@@ -76,6 +76,19 @@ func (d *Driver) Run(ctx context.Context) error {
|
|||||||
// processChanges now takes and modifies the AppState directly.
|
// processChanges now takes and modifies the AppState directly.
|
||||||
func (d *Driver) processChanges(appState *storage.AppState, scrapedBags map[string]crawler.Bag) (bool, []string) {
|
func (d *Driver) processChanges(appState *storage.AppState, scrapedBags map[string]crawler.Bag) (bool, []string) {
|
||||||
var notifications []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
|
hasChanges := false
|
||||||
|
|
||||||
for sku, newBag := range scrapedBags {
|
for sku, newBag := range scrapedBags {
|
||||||
|
|||||||
Reference in New Issue
Block a user