1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 02:39:33 +02:00

Fix removed sha segments on fast restream

This commit is contained in:
Chocobozzz 2022-06-24 09:34:56 +02:00
parent 383dbdec67
commit 92083e4228
No known key found for this signature in database
GPG key ID: 583A612D890159BE
5 changed files with 19 additions and 21 deletions

View file

@ -3,6 +3,7 @@ import { basename, join } from 'path'
import { logger } from '@server/helpers/logger'
import { MStreamingPlaylist, MVideo } from '@server/types/models'
import { getLiveDirectory } from '../paths'
import { LiveSegmentShaStore } from './live-segment-sha-store'
function buildConcatenatedName (segmentOrPlaylistPath: string) {
const num = basename(segmentOrPlaylistPath).match(/^(\d+)(-|\.)/)
@ -11,9 +12,7 @@ function buildConcatenatedName (segmentOrPlaylistPath: string) {
}
async function cleanupPermanentLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
const hlsDirectory = getLiveDirectory(video)
await cleanupTMPLiveFiles(hlsDirectory)
await cleanupTMPLiveFiles(video)
await streamingPlaylist.destroy()
}
@ -24,11 +23,19 @@ async function cleanupUnsavedNormalLive (video: MVideo, streamingPlaylist: MStre
await remove(hlsDirectory)
await streamingPlaylist.destroy()
LiveSegmentShaStore.Instance.cleanupShaSegments(video.uuid)
}
async function cleanupTMPLiveFiles (hlsDirectory: string) {
async function cleanupTMPLiveFiles (video: MVideo) {
const hlsDirectory = getLiveDirectory(video)
LiveSegmentShaStore.Instance.cleanupShaSegments(video.uuid)
if (!await pathExists(hlsDirectory)) return
logger.info('Cleanup TMP live files of %s.', hlsDirectory)
const files = await readdir(hlsDirectory)
for (const filename of files) {