mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
lib/model: Make the (?d) prefix actually work
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3205
This commit is contained in:
parent
242db26343
commit
92a23da3ec
@ -25,6 +25,8 @@ import (
|
||||
"github.com/syncthing/syncthing/lib/config"
|
||||
"github.com/syncthing/syncthing/lib/connections"
|
||||
"github.com/syncthing/syncthing/lib/db"
|
||||
"github.com/syncthing/syncthing/lib/ignore"
|
||||
"github.com/syncthing/syncthing/lib/osutil"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
)
|
||||
|
||||
@ -1420,6 +1422,39 @@ func TestIssue3028(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIssue3164(t *testing.T) {
|
||||
osutil.RemoveAll("testdata/issue3164")
|
||||
defer osutil.RemoveAll("testdata/issue3164")
|
||||
|
||||
if err := os.MkdirAll("testdata/issue3164/oktodelete/foobar", 0777); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := ioutil.WriteFile("testdata/issue3164/oktodelete/foobar/file", []byte("Hello"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := ioutil.WriteFile("testdata/issue3164/oktodelete/file", []byte("Hello"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f := protocol.FileInfo{
|
||||
Name: "issue3164",
|
||||
}
|
||||
m := ignore.New(false)
|
||||
if err := m.Parse(bytes.NewBufferString("(?d)oktodelete"), ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
fl := rwFolder{
|
||||
dbUpdates: make(chan dbUpdateJob, 1),
|
||||
dir: "testdata",
|
||||
}
|
||||
|
||||
fl.deleteDir(f, m)
|
||||
|
||||
if _, err := os.Stat("testdata/issue3164"); !os.IsNotExist(err) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
type fakeAddr struct{}
|
||||
|
||||
func (fakeAddr) Network() string {
|
||||
|
@ -678,7 +678,7 @@ func (f *rwFolder) deleteDir(file protocol.FileInfo, matcher *ignore.Matcher) {
|
||||
for _, dirFile := range files {
|
||||
fullDirFile := filepath.Join(file.Name, dirFile)
|
||||
if defTempNamer.IsTemporary(dirFile) || (matcher != nil && matcher.Match(fullDirFile).IsDeletable()) {
|
||||
osutil.RemoveAll(fullDirFile)
|
||||
osutil.RemoveAll(filepath.Join(f.dir, fullDirFile))
|
||||
}
|
||||
}
|
||||
dir.Close()
|
||||
|
Loading…
Reference in New Issue
Block a user