mirror of
https://github.com/restic/restic.git
synced 2025-12-12 06:32:06 +00:00
restore: use case insensitive file name comparison on windows
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user