Reduce scanning effort

This commit is contained in:
Lode Hoste
2015-07-31 18:52:50 +02:00
parent 5a2db802d9
commit 9b9fe0d65c
3 changed files with 211 additions and 5 deletions

View File

@@ -1227,13 +1227,14 @@ func (m *Model) internalScanFolderSubs(folder string, subs []string) error {
nextSub:
for _, sub := range subs {
for sub != "" {
if _, ok = fs.Get(protocol.LocalDeviceID, sub); ok {
parent := filepath.Dir(sub)
if parent == "." || parent == string(filepath.Separator) {
parent = ""
}
if _, ok = fs.Get(protocol.LocalDeviceID, parent); ok {
break
}
sub = filepath.Dir(sub)
if sub == "." || sub == string(filepath.Separator) {
sub = ""
}
sub = parent
}
for _, us := range unifySubs {
if strings.HasPrefix(sub, us) {

View File

@@ -17,9 +17,11 @@ import (
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
"strconv"
stdsync "sync"
"time"
@@ -233,6 +235,21 @@ func (p *Process) RescanDelay(folder string, delaySeconds int) error {
return err
}
func (p *Process) RescanSub(folder string, sub string, delaySeconds int) error {
return p.RescanSubs(folder, []string{sub}, delaySeconds)
}
func (p *Process) RescanSubs(folder string, subs []string, delaySeconds int) error {
data := url.Values{}
data.Set("folder", folder)
for _, sub := range subs {
data.Add("sub", sub)
}
data.Set("next", strconv.Itoa(delaySeconds))
_, err := p.Post("/rest/db/scan?"+data.Encode(), nil)
return err
}
func (p *Process) ConfigInSync() (bool, error) {
bs, err := p.Get("/rest/system/config/insync")
if err != nil {