lib/model: Don't fail over case-conflict on tempfile (fixes #6973) (#6975)

This commit is contained in:
Simon Frei
2020-09-09 11:47:14 +02:00
committed by GitHub
parent 44658258d2
commit e3cd9219b8
3 changed files with 36 additions and 2 deletions
+26
View File
@@ -1216,6 +1216,32 @@ func testPullCaseOnlyDirOrSymlink(t *testing.T, dir bool) {
}
}
func TestPullTempFileCaseConflict(t *testing.T) {
m, f := setupSendReceiveFolder()
defer cleanupSRFolder(f, m)
copyChan := make(chan copyBlocksState, 1)
file := protocol.FileInfo{Name: "foo"}
confl := "Foo"
tempNameConfl := fs.TempName(confl)
if fd, err := f.fs.Create(tempNameConfl); err != nil {
t.Fatal(err)
} else {
if _, err := fd.Write([]byte("data")); err != nil {
t.Fatal(err)
}
fd.Close()
}
f.handleFile(file, f.fset.Snapshot(), copyChan)
cs := <-copyChan
if _, err := cs.tempFile(); err != nil {
t.Error(err)
}
}
func cleanupSharedPullerState(s *sharedPullerState) {
s.mut.Lock()
defer s.mut.Unlock()