1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-23 08:16:36 +00:00

Fix saving pack: close temp file before removing

This commit is contained in:
Alexander Neumann 2017-01-23 18:45:15 +01:00
parent 03292d10cc
commit 8e722d8fee

View file

@ -111,15 +111,15 @@ func (r *Repository) savePacker(p *Packer) error {
return err
}
f, err := fs.Open(p.tmpfile.Name())
_, err = p.tmpfile.Seek(0, 0)
if err != nil {
return errors.Wrap(err, "Open")
return errors.Wrap(err, "Seek")
}
id := restic.IDFromHash(p.hw.Sum(nil))
h := restic.Handle{Type: restic.DataFile, Name: id.String()}
err = r.be.Save(h, f)
err = r.be.Save(h, p.tmpfile)
if err != nil {
debug.Log("Save(%v) error: %v", h, err)
return err
@ -127,7 +127,7 @@ func (r *Repository) savePacker(p *Packer) error {
debug.Log("saved as %v", h)
err = f.Close()
err = p.tmpfile.Close()
if err != nil {
return errors.Wrap(err, "close tempfile")
}