mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2026-09-03 20:53:09 -05:00
More robust quota exceeded handler
This commit is contained in:
@@ -183,10 +183,6 @@ class LiveManager {
|
||||
})
|
||||
}
|
||||
|
||||
isRunning () {
|
||||
return !!this.rtmpServer
|
||||
}
|
||||
|
||||
hasSession (sessionId: string) {
|
||||
return this.getContext().sessions.has(sessionId)
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ class MuxingSession extends EventEmitter implements MuxingSession {
|
||||
private watchTSFiles () {
|
||||
const startStreamDateTime = new Date().getTime()
|
||||
|
||||
const addHandler = async (segmentPath: string) => {
|
||||
const addHandler = (segmentPath: string) => {
|
||||
if (segmentPath.endsWith('.ts') !== true) return
|
||||
|
||||
logger.debug('Live add handler of TS file %s.', segmentPath, this.lTags())
|
||||
@@ -273,18 +273,9 @@ class MuxingSession extends EventEmitter implements MuxingSession {
|
||||
|
||||
if (this.hasClientSocketInBadHealthWithCache(this.sessionId)) {
|
||||
this.emit('bad-socket-health', { videoUUID: this.videoUUID })
|
||||
return
|
||||
}
|
||||
|
||||
// Duration constraint check
|
||||
if (this.isDurationConstraintValid(startStreamDateTime) !== true) {
|
||||
} // Duration constraint check
|
||||
else if (this.isDurationConstraintValid(startStreamDateTime) !== true) {
|
||||
this.emit('duration-exceeded', { videoUUID: this.videoUUID })
|
||||
return
|
||||
}
|
||||
|
||||
// Check user quota if the user enabled replay saving
|
||||
if (await this.isQuotaExceeded(segmentPath) === true) {
|
||||
this.emit('quota-exceeded', { videoUUID: this.videoUUID })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,6 +370,12 @@ class MuxingSession extends EventEmitter implements MuxingSession {
|
||||
}
|
||||
|
||||
private async processSegment (segmentPath: string) {
|
||||
// Check user quota if the user enabled replay saving
|
||||
if (await this.isQuotaExceeded(segmentPath) === true) {
|
||||
this.emit('quota-exceeded', { videoUUID: this.videoUUID })
|
||||
return
|
||||
}
|
||||
|
||||
// Add sha hash of previous segments, because ffmpeg should have finished generating them
|
||||
await this.liveSegmentShaStore.addSegmentSha(segmentPath)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user