restore: use case insensitive file name comparison on windows

This commit is contained in:
Michael Eischer
2024-06-29 19:54:12 +02:00
parent 013a6156bd
commit 168fc09d5f
4 changed files with 59 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import (
"math"
"os"
"path"
"path/filepath"
"syscall"
"testing"
"time"
@@ -539,3 +540,36 @@ func TestDirAttributeCombinationsOverwrite(t *testing.T) {
}
}
}
func TestRestoreDeleteCaseInsensitive(t *testing.T) {
repo := repository.TestRepository(t)
tempdir := rtest.TempDir(t)
sn, _ := saveSnapshot(t, repo, Snapshot{
Nodes: map[string]Node{
"anotherfile": File{Data: "content: file\n"},
},
}, noopGetGenericAttributes)
// should delete files that no longer exist in the snapshot
deleteSn, _ := saveSnapshot(t, repo, Snapshot{
Nodes: map[string]Node{
"AnotherfilE": File{Data: "content: file\n"},
},
}, noopGetGenericAttributes)
res := NewRestorer(repo, sn, Options{})
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := res.RestoreTo(ctx, tempdir)
rtest.OK(t, err)
res = NewRestorer(repo, deleteSn, Options{Delete: true})
err = res.RestoreTo(ctx, tempdir)
rtest.OK(t, err)
// anotherfile must still exist
_, err = os.Stat(filepath.Join(tempdir, "anotherfile"))
rtest.OK(t, err)
}