mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 19:08:55 +00:00
Fix error on temp file deletion on windows
Apparently it can take a moment between closing a tempfile marked as DELETE_ON_CLOSE and it actually being deleted. During that time the file is inaccessible. Thus just skip deleting the temp file on windows.
This commit is contained in:
parent
ab49c14621
commit
ae7e51382a
@ -5,6 +5,7 @@ import (
|
||||
"hash"
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"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")
|
||||
}
|
||||
|
||||
err = fs.RemoveIfExists(p.tmpfile.Name())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Remove")
|
||||
// on windows the tempfile is automatically deleted on close
|
||||
if runtime.GOOS != "windows" {
|
||||
err = fs.RemoveIfExists(p.tmpfile.Name())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Remove")
|
||||
}
|
||||
}
|
||||
|
||||
// update blobs in the index
|
||||
|
Loading…
Reference in New Issue
Block a user