aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index f3a2308..7950af9 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -348,7 +348,6 @@ func (d *DotGit) rewritePackedRefsWithoutRef(name plumbing.ReferenceName) (err e
return err
}
- defer ioutil.CheckClose(f, &err)
// Creating the temp file in the same directory as the target file
// improves our chances for rename operation to be atomic.
@@ -357,10 +356,6 @@ func (d *DotGit) rewritePackedRefsWithoutRef(name plumbing.ReferenceName) (err e
return err
}
- tmpPath := tmp.Name()
- defer ioutil.CheckClose(tmp, &err)
- defer d.fs.Remove(tmpPath)
-
s := bufio.NewScanner(f)
found := false
for s.Scan() {
@@ -388,7 +383,15 @@ func (d *DotGit) rewritePackedRefsWithoutRef(name plumbing.ReferenceName) (err e
return nil
}
- return d.fs.Rename(tmpPath, packedRefsPath)
+ if err := f.Close(); err != nil {
+ return err
+ }
+
+ if err := tmp.Close(); err != nil {
+ return err
+ }
+
+ return d.fs.Rename(tmp.Name(), packedRefsPath)
}
// process lines from a packed-refs file