Reduce scanning effort
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user