mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 12:14:46 -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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
@ -61,6 +62,7 @@ func (fs *FileStream) Kill() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FileStream) Destroy() {
|
func (fs *FileStream) Destroy() {
|
||||||
|
log.Printf("Removing all transcode cache files for %s", fs.Path)
|
||||||
fs.Kill()
|
fs.Kill()
|
||||||
_ = os.RemoveAll(fs.Out)
|
_ = os.RemoveAll(fs.Out)
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,11 @@ type Tracker struct {
|
|||||||
|
|
||||||
func NewTracker(t *Transcoder) *Tracker {
|
func NewTracker(t *Transcoder) *Tracker {
|
||||||
ret := &Tracker{
|
ret := &Tracker{
|
||||||
clients: make(map[string]ClientInfo),
|
clients: make(map[string]ClientInfo),
|
||||||
visitDate: make(map[string]time.Time),
|
visitDate: make(map[string]time.Time),
|
||||||
lastUsage: make(map[string]time.Time),
|
lastUsage: make(map[string]time.Time),
|
||||||
transcoder: t,
|
deletedStream: make(chan string),
|
||||||
|
transcoder: t,
|
||||||
}
|
}
|
||||||
go ret.start()
|
go ret.start()
|
||||||
return ret
|
return ret
|
||||||
@ -94,6 +95,8 @@ func (t *Tracker) start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info := t.clients[client]
|
info := t.clients[client]
|
||||||
|
delete(t.clients, client)
|
||||||
|
delete(t.visitDate, client)
|
||||||
|
|
||||||
if !t.KillStreamIfDead(info.path) {
|
if !t.KillStreamIfDead(info.path) {
|
||||||
audio_cleanup := info.audio != -1 && t.KillAudioIfDead(info.path, info.audio)
|
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)
|
t.KillOrphanedHeads(info.path, info.quality, info.audio)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(t.clients, client)
|
|
||||||
delete(t.visitDate, client)
|
|
||||||
}
|
}
|
||||||
case path := <-t.deletedStream:
|
case path := <-t.deletedStream:
|
||||||
t.DestroyStreamIfOld(path)
|
t.DestroyStreamIfOld(path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user