From ea9f8b0cebbeac6468923363b974464b25457a85 Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Wed, 15 Oct 2014 10:30:04 +0100 Subject: [PATCH] Cleanup temporaries once an hour (fixes #858) --- internal/model/puller.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/model/puller.go b/internal/model/puller.go index 2e1548ca3..b055f7e89 100644 --- a/internal/model/puller.go +++ b/internal/model/puller.go @@ -84,16 +84,21 @@ func (p *Puller) Serve() { pullTimer := time.NewTimer(checkPullIntv) scanTimer := time.NewTimer(time.Millisecond) // The first scan should be done immediately. + cleanTimer := time.NewTicker(time.Hour) defer func() { pullTimer.Stop() scanTimer.Stop() + cleanTimer.Stop() // TODO: Should there be an actual FolderStopped state? p.model.setState(p.folder, FolderIdle) }() 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. initialScanCompleted := false @@ -128,9 +133,6 @@ loop: continue } - // Clean out old temporaries before we start pulling - p.clean() - if debug { l.Debugln(p, "pulling", prevVer, curVer) } @@ -197,6 +199,9 @@ loop: l.Infoln("Completed initial scan (rw) of folder", p.folder) initialScanCompleted = true } + // Clean out old temporaries + case <-cleanTimer.C: + p.clean() } } }