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+)(-|\.)/)
}
async function cleanupPermanentLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) {
- const hlsDirectory = getLiveDirectory(video)
-
- await cleanupTMPLiveFiles(hlsDirectory)
+ await cleanupTMPLiveFiles(video)
await streamingPlaylist.destroy()
}
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) {