Skip to content
Browse files

Save/LoadFile must close file

  • Loading branch information...
1 parent 72916cf commit a768a84319c9c8b1b9131e6592e9488de89ff257 @temoto temoto committed
Showing with 12 additions and 2 deletions.
  1. +12 −2 cache.go
View
14 cache.go
@@ -292,7 +292,12 @@ func (c *cache) SaveFile(fname string) error {
if err != nil {
return err
}
- return c.Save(fp)
+ err = c.Save(fp)
+ if err != nil {
+ fp.Close()
+ return err
+ }
+ return fp.Close()
}
// Add (Gob-serialized) cache items from an io.Reader, excluding any items with
@@ -319,7 +324,12 @@ func (c *cache) LoadFile(fname string) error {
if err != nil {
return err
}
- return c.Load(fp)
+ err = c.Load(fp)
+ if err != nil {
+ fp.Close()
+ return err
+ }
+ return fp.Close()
}
// Delete all items from the cache.

0 comments on commit a768a84

Please sign in to comment.
Something went wrong with that request. Please try again.