mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
Merge pull request #860 from AudriusButkevicius/ticker
Cleanup temporaries once an hour (fixes #858)
This commit is contained in:
commit
cd05f1c3d7
@ -84,16 +84,21 @@ func (p *Puller) Serve() {
|
|||||||
|
|
||||||
pullTimer := time.NewTimer(checkPullIntv)
|
pullTimer := time.NewTimer(checkPullIntv)
|
||||||
scanTimer := time.NewTimer(time.Millisecond) // The first scan should be done immediately.
|
scanTimer := time.NewTimer(time.Millisecond) // The first scan should be done immediately.
|
||||||
|
cleanTimer := time.NewTicker(time.Hour)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
pullTimer.Stop()
|
pullTimer.Stop()
|
||||||
scanTimer.Stop()
|
scanTimer.Stop()
|
||||||
|
cleanTimer.Stop()
|
||||||
// TODO: Should there be an actual FolderStopped state?
|
// TODO: Should there be an actual FolderStopped state?
|
||||||
p.model.setState(p.folder, FolderIdle)
|
p.model.setState(p.folder, FolderIdle)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var prevVer uint64
|
var prevVer uint64
|
||||||
|
|
||||||
|
// Clean out old temporaries before we start pulling
|
||||||
|
p.clean()
|
||||||
|
|
||||||
// We don't start pulling files until a scan has been completed.
|
// We don't start pulling files until a scan has been completed.
|
||||||
initialScanCompleted := false
|
initialScanCompleted := false
|
||||||
|
|
||||||
@ -128,9 +133,6 @@ loop:
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean out old temporaries before we start pulling
|
|
||||||
p.clean()
|
|
||||||
|
|
||||||
if debug {
|
if debug {
|
||||||
l.Debugln(p, "pulling", prevVer, curVer)
|
l.Debugln(p, "pulling", prevVer, curVer)
|
||||||
}
|
}
|
||||||
@ -197,6 +199,9 @@ loop:
|
|||||||
l.Infoln("Completed initial scan (rw) of folder", p.folder)
|
l.Infoln("Completed initial scan (rw) of folder", p.folder)
|
||||||
initialScanCompleted = true
|
initialScanCompleted = true
|
||||||
}
|
}
|
||||||
|
// Clean out old temporaries
|
||||||
|
case <-cleanTimer.C:
|
||||||
|
p.clean()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user