forked from TrueCloudLab/restic
Merge pull request #3744 from MichaelEischer/fix-windows-temp-file
Fix error on temp file deletion on windows
This commit is contained in:
commit
c270ab1e08
1 changed files with 7 additions and 3 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"hash"
|
"hash"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/errors"
|
"github.com/restic/restic/internal/errors"
|
||||||
|
@ -137,9 +138,12 @@ func (r *Repository) savePacker(ctx context.Context, t restic.BlobType, p *Packe
|
||||||
return errors.Wrap(err, "close tempfile")
|
return errors.Wrap(err, "close tempfile")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = fs.RemoveIfExists(p.tmpfile.Name())
|
// on windows the tempfile is automatically deleted on close
|
||||||
if err != nil {
|
if runtime.GOOS != "windows" {
|
||||||
return errors.Wrap(err, "Remove")
|
err = fs.RemoveIfExists(p.tmpfile.Name())
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "Remove")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// update blobs in the index
|
// update blobs in the index
|
||||||
|
|
Loading…
Reference in a new issue