mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
Make sure we start scanning at an indexed location (fixes #1399)
This commit is contained in:
parent
e22c873ec4
commit
57fc0eb5b1
@ -1146,6 +1146,7 @@ func (m *Model) ScanFolder(folder string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Model) ScanFolderSub(folder, sub string) error {
|
func (m *Model) ScanFolderSub(folder, sub string) error {
|
||||||
|
sub = osutil.NativeFilename(sub)
|
||||||
if p := filepath.Clean(filepath.Join(folder, sub)); !strings.HasPrefix(p, folder) {
|
if p := filepath.Clean(filepath.Join(folder, sub)); !strings.HasPrefix(p, folder) {
|
||||||
return errors.New("invalid subpath")
|
return errors.New("invalid subpath")
|
||||||
}
|
}
|
||||||
@ -1162,6 +1163,18 @@ func (m *Model) ScanFolderSub(folder, sub string) error {
|
|||||||
|
|
||||||
_ = ignores.Load(filepath.Join(folderCfg.Path, ".stignore")) // Ignore error, there might not be an .stignore
|
_ = ignores.Load(filepath.Join(folderCfg.Path, ".stignore")) // Ignore error, there might not be an .stignore
|
||||||
|
|
||||||
|
// Required to make sure that we start indexing at a directory we're already
|
||||||
|
// aware off.
|
||||||
|
for sub != "" {
|
||||||
|
if _, ok = fs.Get(protocol.LocalDeviceID, sub); ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
sub = filepath.Dir(sub)
|
||||||
|
if sub == "." || sub == string(filepath.Separator) {
|
||||||
|
sub = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
w := &scanner.Walker{
|
w := &scanner.Walker{
|
||||||
Dir: folderCfg.Path,
|
Dir: folderCfg.Path,
|
||||||
Sub: sub,
|
Sub: sub,
|
||||||
|
Loading…
Reference in New Issue
Block a user