- const fullVideo = await VideoModel.loadAndPopulateAccountAndServerAndTags(liveVideo.id)
- return federateVideoIfNeeded(fullVideo, false, undefined)
-}
-
-async function cleanupTMPLiveFiles (hlsDirectory: string) {
- if (!await pathExists(hlsDirectory)) return
-
- const files = await readdir(hlsDirectory)
-
- for (const filename of files) {
- if (
- filename.endsWith('.ts') ||
- filename.endsWith('.m3u8') ||
- filename.endsWith('.mpd') ||
- filename.endsWith('.m4s') ||
- filename.endsWith('.tmp')
- ) {
- const p = join(hlsDirectory, filename)
-
- remove(p)
- .catch(err => logger.error('Cannot remove %s.', p, { err }))
+ if (streamingPlaylist) {
+ if (permanentLive) {
+ await cleanupAndDestroyPermanentLive(video, streamingPlaylist)
+ } else {
+ await cleanupUnsavedNormalLive(video, streamingPlaylist)