Skip to content

Commit

Permalink
fix(console): Save SRAM even if autosave fails during close
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jun 18, 2024
1 parent b2a91fc commit 95d7da7
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions internal/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,15 @@ func New(conf *config.Config, cart *cartridge.Cartridge) (*Console, error) {
}

func (c *Console) Close() error {
var errs []error
if c.autosave != nil {
c.autosave.Stop()
}
if c.config.State.Resume {
if err := c.SaveStateNum(AutoSaveNum, false); err != nil {
return err
}
}
if err := c.SaveSRAM(); err != nil {
return err
errs = append(errs, c.SaveStateNum(AutoSaveNum, false))
}
return nil
errs = append(errs, c.SaveSRAM())
return errors.Join(errs...)
}

func (c *Console) Step(render bool) {
Expand Down

0 comments on commit 95d7da7

Please sign in to comment.