forked from TrueCloudLab/restic
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
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,10 +138,13 @@ func (r *Repository) savePacker(ctx context.Context, t restic.BlobType, p *Packe
|
||||||
return errors.Wrap(err, "close tempfile")
|
return errors.Wrap(err, "close tempfile")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// on windows the tempfile is automatically deleted on close
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
err = fs.RemoveIfExists(p.tmpfile.Name())
|
err = fs.RemoveIfExists(p.tmpfile.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Remove")
|
return errors.Wrap(err, "Remove")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// update blobs in the index
|
// update blobs in the index
|
||||||
debug.Log(" updating blobs %v to pack %v", p.Packer.Blobs(), id)
|
debug.Log(" updating blobs %v to pack %v", p.Packer.Blobs(), id)
|
||||||
|
|
Loading…
Reference in a new issue