only save state if has changes
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m47s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m47s
This commit is contained in:
7
main.go
7
main.go
@@ -53,16 +53,23 @@ type App struct {
|
||||
}
|
||||
|
||||
func (a *App) Save() error {
|
||||
hasChanges := false
|
||||
for id, grain := range a.pool.GetGrains() {
|
||||
if grain == nil {
|
||||
continue
|
||||
}
|
||||
if grain.GetLastChange() > a.storage.LastSaves[id] {
|
||||
hasChanges = true
|
||||
log.Printf("Saving grain %s\n", id)
|
||||
err := a.storage.Store(id, grain)
|
||||
if err != nil {
|
||||
log.Printf("Error saving grain %s: %v\n", id, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !hasChanges {
|
||||
return nil
|
||||
}
|
||||
return a.storage.saveState()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user