lib/model: Allow empty subdirs in scan request (fixes #3829)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3833
This commit is contained in:
parent
ba17cc0a11
commit
226da976dc
@ -1706,8 +1706,16 @@ func (m *Model) ScanFolderSubdirs(folder string, subs []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) internalScanFolderSubdirs(folder string, subDirs []string) error {
|
func (m *Model) internalScanFolderSubdirs(folder string, subDirs []string) error {
|
||||||
for i, sub := range subDirs {
|
for i := 0; i < len(subDirs); i++ {
|
||||||
sub = osutil.NativeFilename(sub)
|
sub := osutil.NativeFilename(subDirs[i])
|
||||||
|
|
||||||
|
if sub == "" {
|
||||||
|
// A blank subdirs means to scan the entire folder. We can trim
|
||||||
|
// the subDirs list and go on our way.
|
||||||
|
subDirs = nil
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
// We test each path by joining with "root". What we join with is
|
// We test each path by joining with "root". What we join with is
|
||||||
// not relevant, we just want the dotdot escape detection here. For
|
// not relevant, we just want the dotdot escape detection here. For
|
||||||
// historical reasons we may get paths that end in a slash. We
|
// historical reasons we may get paths that end in a slash. We
|
||||||
|
|||||||
@ -2181,6 +2181,21 @@ func TestIssue3804(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue3829(t *testing.T) {
|
||||||
|
dbi := db.OpenMemory()
|
||||||
|
m := NewModel(defaultConfig, protocol.LocalDeviceID, "device", "syncthing", "dev", dbi, nil)
|
||||||
|
m.AddFolder(defaultFolderConfig)
|
||||||
|
m.StartFolder("default")
|
||||||
|
m.ServeBackground()
|
||||||
|
defer m.Stop()
|
||||||
|
|
||||||
|
// Empty subdirs should be accepted
|
||||||
|
|
||||||
|
if err := m.ScanFolderSubdirs("default", []string{""}); err != nil {
|
||||||
|
t.Error("Unexpected error:", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRootedJoinedPath(t *testing.T) {
|
func TestRootedJoinedPath(t *testing.T) {
|
||||||
type testcase struct {
|
type testcase struct {
|
||||||
root string
|
root string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user