From 6c33188af320e76ce18bc46e49e02a586df318ec Mon Sep 17 00:00:00 2001 From: Michael Ploujnikov Date: Fri, 22 Jan 2016 22:25:43 -0500 Subject: [PATCH 1/2] Model.internalScanFolderSubs: Scan only requested subs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts the change introduced in 9b9fe0d Reduce scanning effort. That commit caused us to automatically ignore the basename of the specified subs and instead scan closest known root folder. For example, in a folder that looks like: Sync/ ├── 00 │   ├── one │   ├── three │   └── two ├── 01 │   ├── one │   ├── three │   └── two ├── 02 │   ├── one │   ├── three │   └── two └── one calling '/rest/db/scan?folder=default&sub=01' called filepath.Walk on the whole Sync/ folder instead of just the desired subfolder. This contradicts the scan behavior promised by the documentation. This is related to #2151. --- lib/model/model.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/model/model.go b/lib/model/model.go index 00f7ad891..5ed5e8973 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -1324,14 +1324,13 @@ func (m *Model) internalScanFolderSubs(folder string, subs []string) error { nextSub: for _, sub := range subs { for sub != "" { - parent := filepath.Dir(sub) - if parent == "." || parent == string(filepath.Separator) { - parent = "" - } - if _, ok = fs.Get(protocol.LocalDeviceID, parent); ok { + if _, ok = fs.Get(protocol.LocalDeviceID, sub); ok { break } - sub = parent + sub = filepath.Dir(sub) + if sub == "." || sub == string(filepath.Separator) { + sub = "" + } } for _, us := range unifySubs { if strings.HasPrefix(sub, us) { From 49601a63c870c51404de124589414731f28e6004 Mon Sep 17 00:00:00 2001 From: Michael Ploujnikov Date: Fri, 22 Jan 2016 22:37:58 -0500 Subject: [PATCH 2/2] Model.internalScanFolder: Don't ignore special .stfolder and .stignore files. Fixes #2151. Since Walk.walkAndHashFiles ignores .stfolder and .stignore, they will never be found by fs.Get(protocol.LocalDeviceID, sub) in Model.internalScanFolder. As a result, when asked to scan those subs we end up scanning the whole folder. --- lib/model/model.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/model/model.go b/lib/model/model.go index 5ed5e8973..5ea775394 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -1323,7 +1323,7 @@ func (m *Model) internalScanFolderSubs(folder string, subs []string) error { var unifySubs []string nextSub: for _, sub := range subs { - for sub != "" { + for sub != "" && sub != ".stfolder" && sub != ".stignore" { if _, ok = fs.Get(protocol.LocalDeviceID, sub); ok { break }