diff --git a/commonspace/settings/deleteloop.go b/commonspace/settings/deleteloop.go index b479020c..fe244ab6 100644 --- a/commonspace/settings/deleteloop.go +++ b/commonspace/settings/deleteloop.go @@ -2,8 +2,11 @@ package settings import ( "context" + "time" ) +const deleteLoopInterval = time.Second * 20 + type deleteLoop struct { deleteCtx context.Context deleteCancel context.CancelFunc @@ -30,12 +33,17 @@ func (dl *deleteLoop) Run() { func (dl *deleteLoop) loop() { defer close(dl.loopDone) dl.deleteFunc() + ticker := time.NewTicker(deleteLoopInterval) + defer ticker.Stop() for { select { case <-dl.deleteCtx.Done(): return case <-dl.deleteChan: dl.deleteFunc() + ticker.Reset(deleteLoopInterval) + case <-ticker.C: + dl.deleteFunc() } } }