Reset the directories when the stream gets disconnected (#152)

* Reset the directories when the stream gets disconnected

* Cleanup after a delay

Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
Bradley Hilton
2020-09-16 15:31:21 -05:00
committed by GitHub
parent 80b2b9e668
commit dd9267f1ee
2 changed files with 26 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import (
"os"
"path"
"strconv"
"time"
log "github.com/sirupsen/logrus"
@@ -15,8 +16,9 @@ import (
)
var (
_stats *models.Stats
_storage models.ChunkStorageProvider
_stats *models.Stats
_storage models.ChunkStorageProvider
_cleanupTicker *time.Ticker
)
//Start starts up the core processing
@@ -56,6 +58,25 @@ func createInitialOfflineState() error {
return nil
}
func startCleanupTimer() {
_cleanupTicker := time.NewTicker(5 * time.Minute)
go func() {
for {
select {
case <-_cleanupTicker.C:
resetDirectories()
}
}
}()
}
// StopCleanupTimer will stop the previous cleanup timer
func stopCleanupTimer() {
if _cleanupTicker != nil {
_cleanupTicker.Stop()
}
}
func resetDirectories() {
log.Trace("Resetting file directories to a clean slate.")