forked from TrueCloudLab/restic
backup: work around file deletion error in test
This commit is contained in:
parent
fc6f1b4b06
commit
e1faf7b18c
1 changed files with 12 additions and 1 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/fs"
|
"github.com/restic/restic/internal/fs"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
|
@ -122,7 +123,17 @@ func (f *vssDeleteOriginalFS) Lstat(name string) (os.FileInfo, error) {
|
||||||
// call Lstat to trigger snapshot creation
|
// call Lstat to trigger snapshot creation
|
||||||
_, _ = f.FS.Lstat(name)
|
_, _ = f.FS.Lstat(name)
|
||||||
// nuke testdata
|
// nuke testdata
|
||||||
if err := os.RemoveAll(f.testdata); err != nil {
|
var err error
|
||||||
|
for i := 0; i < 3; i++ {
|
||||||
|
// The CI sometimes runs into "The process cannot access the file because it is being used by another process" errors
|
||||||
|
// thus try a few times to remove the data
|
||||||
|
err = os.RemoveAll(f.testdata)
|
||||||
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
f.hasRemoved = true
|
f.hasRemoved = true
|
||||||
|
|
Loading…
Reference in a new issue