Merge pull request #4 from temoto/patch-1

Attempt to close the file in SaveFile/LoadFile, and return either the serialization error, or the Close() error.
This commit is contained in:
Patrick Mylund Nielsen 2012-10-08 03:27:04 -07:00
commit e30c8eff7a
1 changed files with 12 additions and 2 deletions

View File

@ -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.