aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/index.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-07-19 22:05:00 +0200
committerGitHub <noreply@github.com>2017-07-19 22:05:00 +0200
commit2d10f1023e609894174b21bdf8d3738010099335 (patch)
tree929b050b54039af69b4eae6306429feafa9d8268 /storage/filesystem/index.go
parent8738a04708b91683d5804b4c648c871fdeb87f82 (diff)
parent87888eaab1caa52b6b073f610508e0f65b4141f6 (diff)
downloadgo-git-2d10f1023e609894174b21bdf8d3738010099335.tar.gz
Merge pull request #491 from smola/error-checks
*: add more IO error checks
Diffstat (limited to 'storage/filesystem/index.go')
-rw-r--r--storage/filesystem/index.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/storage/filesystem/index.go b/storage/filesystem/index.go
index 456ef0b..14ab09a 100644
--- a/storage/filesystem/index.go
+++ b/storage/filesystem/index.go
@@ -5,6 +5,7 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing/format/index"
"gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit"
+ "gopkg.in/src-d/go-git.v4/utils/ioutil"
)
type IndexStorage struct {
@@ -17,10 +18,11 @@ func (s *IndexStorage) SetIndex(idx *index.Index) error {
return err
}
- defer f.Close()
+ defer ioutil.CheckClose(f, &err)
e := index.NewEncoder(f)
- return e.Encode(idx)
+ err = e.Encode(idx)
+ return err
}
func (s *IndexStorage) Index() (*index.Index, error) {
@@ -37,8 +39,9 @@ func (s *IndexStorage) Index() (*index.Index, error) {
return nil, err
}
- defer f.Close()
+ defer ioutil.CheckClose(f, &err)
d := index.NewDecoder(f)
- return idx, d.Decode(idx)
+ err = d.Decode(idx)
+ return idx, err
}