Skip to content

Commit

Permalink
fix: Do not return an error in PersistIfDirty
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasdietrich committed Mar 5, 2024
1 parent 60a38ae commit efe2830
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ func (c *Cache) load() error {

}

func (c *Cache) PersistIfDirty() error {
func (c *Cache) PersistIfDirty() {
if !c.dirty {
slog.Debug("cache is not dirty, skip writing")
return nil
return
}

slog.Info("writing cache", slog.String("filename", c.filename))

f, err := os.OpenFile(c.filename, os.O_CREATE|os.O_WRONLY, 0600)
if err != nil {
slog.Error("could not write cache", slog.Any("err", err))
return err
return
}

defer f.Close()
Expand All @@ -59,8 +59,6 @@ func (c *Cache) PersistIfDirty() error {
slog.Debug("clearing cache dirty flag")
c.dirty = false
}

return err
}

func (c *Cache) Get(key string) string {
Expand Down

0 comments on commit efe2830

Please sign in to comment.