Fix scan interval for slow scans

This commit is contained in:
Jakob Borg 2014-07-17 13:39:04 +02:00
parent f88a7a8e6a
commit 0a804e39a8

View File

@ -127,9 +127,10 @@ func (p *puller) run() {
}
}()
walkTicker := time.Tick(time.Duration(p.cfg.Options.RescanIntervalS) * time.Second)
timeout := time.Tick(5 * time.Second)
changed := true
scanintv := time.Duration(p.cfg.Options.RescanIntervalS) * time.Second
lastscan := time.Now()
var prevVer uint64
for {
@ -179,18 +180,17 @@ func (p *puller) run() {
p.model.setState(p.repoCfg.ID, RepoIdle)
// Do a rescan if it's time for it
select {
case <-walkTicker:
if time.Since(lastscan) > scanintv {
if debug {
l.Debugf("%q: time for rescan", p.repoCfg.ID)
}
err := p.model.ScanRepo(p.repoCfg.ID)
if err != nil {
invalidateRepo(p.cfg, p.repoCfg.ID, err)
return
}
default:
lastscan = time.Now()
}
if v := p.model.LocalVersion(p.repoCfg.ID); v > prevVer {