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:
25
core/core.go
25
core/core.go
@@ -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.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user