mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Prevent afk users from preventing transcode cleanup (#487)
This commit is contained in:
parent
bbe88382e5
commit
d5d15eaea6
@ -2,6 +2,7 @@ package src
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"strings"
|
||||
@ -61,6 +62,7 @@ func (fs *FileStream) Kill() {
|
||||
}
|
||||
|
||||
func (fs *FileStream) Destroy() {
|
||||
log.Printf("Removing all transcode cache files for %s", fs.Path)
|
||||
fs.Kill()
|
||||
_ = os.RemoveAll(fs.Out)
|
||||
}
|
||||
|
@ -26,10 +26,11 @@ type Tracker struct {
|
||||
|
||||
func NewTracker(t *Transcoder) *Tracker {
|
||||
ret := &Tracker{
|
||||
clients: make(map[string]ClientInfo),
|
||||
visitDate: make(map[string]time.Time),
|
||||
lastUsage: make(map[string]time.Time),
|
||||
transcoder: t,
|
||||
clients: make(map[string]ClientInfo),
|
||||
visitDate: make(map[string]time.Time),
|
||||
lastUsage: make(map[string]time.Time),
|
||||
deletedStream: make(chan string),
|
||||
transcoder: t,
|
||||
}
|
||||
go ret.start()
|
||||
return ret
|
||||
@ -94,6 +95,8 @@ func (t *Tracker) start() {
|
||||
}
|
||||
|
||||
info := t.clients[client]
|
||||
delete(t.clients, client)
|
||||
delete(t.visitDate, client)
|
||||
|
||||
if !t.KillStreamIfDead(info.path) {
|
||||
audio_cleanup := info.audio != -1 && t.KillAudioIfDead(info.path, info.audio)
|
||||
@ -102,9 +105,6 @@ func (t *Tracker) start() {
|
||||
t.KillOrphanedHeads(info.path, info.quality, info.audio)
|
||||
}
|
||||
}
|
||||
|
||||
delete(t.clients, client)
|
||||
delete(t.visitDate, client)
|
||||
}
|
||||
case path := <-t.deletedStream:
|
||||
t.DestroyStreamIfOld(path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user