more cleanup

This commit is contained in:
2025-10-11 10:34:48 +02:00
parent 4cacc0ee2d
commit 6345d91ef7
2 changed files with 43 additions and 47 deletions

16
main.go
View File

@@ -49,10 +49,10 @@ func spawn(id CartId) (*CartGrain, error) {
ret.lastChange = time.Now().Unix()
// Legacy loadMessages (no-op) retained; then replay append-only event log
_ = loadMessages(ret, id)
_ = ReplayCartEvents(ret, id)
//_ = loadMessages(ret, id)
err := ReplayCartEvents(ret, id)
return ret, nil
return ret, err
}
func init() {
@@ -65,7 +65,7 @@ type App struct {
}
func (a *App) Save() error {
hasChanges := false
a.pool.mu.RLock()
defer a.pool.mu.RUnlock()
for id, grain := range a.pool.GetGrains() {
@@ -73,7 +73,7 @@ func (a *App) Save() error {
continue
}
if grain.GetLastChange() > a.storage.LastSaves[uint64(id)] {
hasChanges = true
err := a.storage.Store(id, grain)
if err != nil {
log.Printf("Error saving grain %s: %v\n", id, err)
@@ -81,10 +81,8 @@ func (a *App) Save() error {
}
}
if !hasChanges {
return nil
}
return a.storage.saveState()
return nil
}
func (a *App) HandleSave(w http.ResponseWriter, r *http.Request) {