lib/model: Fix child-check when deleting dirs in pull (#7236)
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -1350,6 +1351,32 @@ func TestPullDeleteCaseConflict(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPullDeleteIgnoreChildDir(t *testing.T) {
|
||||
m, f := setupSendReceiveFolder(t)
|
||||
defer cleanupSRFolder(f, m)
|
||||
|
||||
parent := "parent"
|
||||
del := "ignored"
|
||||
child := "keep"
|
||||
matcher := ignore.New(f.mtimefs)
|
||||
must(t, matcher.Parse(bytes.NewBufferString(fmt.Sprintf(`
|
||||
!%v
|
||||
(?d)%v
|
||||
`, child, del)), ""))
|
||||
f.ignores = matcher
|
||||
|
||||
must(t, f.mtimefs.Mkdir(parent, 0777))
|
||||
must(t, f.mtimefs.Mkdir(filepath.Join(parent, del), 0777))
|
||||
must(t, f.mtimefs.Mkdir(filepath.Join(parent, del, child), 0777))
|
||||
|
||||
scanChan := make(chan string, 2)
|
||||
|
||||
err := f.deleteDirOnDisk(parent, f.fset.Snapshot(), scanChan)
|
||||
if err == nil {
|
||||
t.Error("no error")
|
||||
}
|
||||
}
|
||||
|
||||
func cleanupSharedPullerState(s *sharedPullerState) {
|
||||
s.mut.Lock()
|
||||
defer s.mut.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user