PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME = 5000
- VIDEO_LIVE.CLEANUP_DELAY = getIntEnv('PEERTUBE_TEST_CONSTANTS.VIDEO_LIVE.CLEANUP_DELAY') ?? 5000
+ VIDEO_LIVE.CLEANUP_DELAY = getIntEnv('PEERTUBE_TEST_CONSTANTS_VIDEO_LIVE_CLEANUP_DELAY') ?? 5000
VIDEO_LIVE.SEGMENT_TIME_SECONDS.DEFAULT_LATENCY = 2
VIDEO_LIVE.SEGMENT_TIME_SECONDS.SMALL_LATENCY = 1
VIDEO_LIVE.EDGE_LIVE_DELAY_SEGMENTS_NOTIFICATION = 1
import { ffprobePromise, getAudioStream, getVideoStreamDimensionsInfo, getVideoStreamDuration } from '@server/helpers/ffmpeg'
import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'
import { federateVideoIfNeeded } from '@server/lib/activitypub/videos'
-import { cleanupUnsavedNormalLive, cleanupPermanentLive, cleanupTMPLiveFiles, LiveSegmentShaStore } from '@server/lib/live'
-import {
- generateHLSMasterPlaylistFilename,
- generateHlsSha256SegmentsFilename,
- getLiveDirectory,
- getLiveReplayBaseDirectory
-} from '@server/lib/paths'
+import { cleanupPermanentLive, cleanupTMPLiveFiles, cleanupUnsavedNormalLive } from '@server/lib/live'
+import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveReplayBaseDirectory } from '@server/lib/paths'
import { generateVideoMiniature } from '@server/lib/thumbnail'
import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/transcoding'
import { moveToNextState } from '@server/lib/video-state'
return
}
- LiveSegmentShaStore.Instance.cleanupShaSegments(liveVideo.uuid)
-
if (live.saveReplay !== true) {
return cleanupLiveAndFederate({ live, video: liveVideo, streamingPlaylistId: payload.streamingPlaylistId })
}
}) {
const { liveVideo, liveSession, live, replayDirectory } = options
- await cleanupTMPLiveFiles(getLiveDirectory(liveVideo))
+ await cleanupTMPLiveFiles(liveVideo)
await live.destroy()
import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getLiveReplayBaseDirectory } from '../paths'
import { PeerTubeSocket } from '../peertube-socket'
import { LiveQuotaStore } from './live-quota-store'
-import { LiveSegmentShaStore } from './live-segment-sha-store'
import { cleanupPermanentLive } from './live-utils'
import { MuxingSession } from './shared'
return this.abortSession(sessionId)
}
- // Cleanup old potential live files (could happen with a permanent live)
- LiveSegmentShaStore.Instance.cleanupShaSegments(video.uuid)
-
+ // Cleanup old potential live (could happen with a permanent live)
const oldStreamingPlaylist = await VideoStreamingPlaylistModel.loadHLSPlaylistByVideo(video.id)
if (oldStreamingPlaylist) {
if (!videoLive.permanentLive) throw new Error('Found previous session in a non permanent live: ' + video.uuid)
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) {
}
async function ensureLastLiveWorks (liveId: string) {
- // Equivalent to PEERTUBE_TEST_CONSTANTS.VIDEO_LIVE.CLEANUP_DELAY
+ // Equivalent to PEERTUBE_TEST_CONSTANTS_VIDEO_LIVE_CLEANUP_DELAY
for (let i = 0; i < 100; i++) {
const video = await server.videos.get({ id: liveId })
expect(video.streamingPlaylists).to.have.lengthOf(1)
await server.live.getSegment({ videoUUID: liveId, segment: 0, playlistNumber: 0 })
await makeRawRequest(video.streamingPlaylists[0].playlistUrl, HttpStatusCode.OK_200)
+ await makeRawRequest(video.streamingPlaylists[0].segmentsSha256Url, HttpStatusCode.OK_200)
await wait(100)
}
before(async function () {
this.timeout(120000)
- const env = { 'PEERTUBE_TEST_CONSTANTS.VIDEO_LIVE.CLEANUP_DELAY': '10000' }
+ const env = { 'PEERTUBE_TEST_CONSTANTS_VIDEO_LIVE_CLEANUP_DELAY': '10000' }
server = await createSingleServer(1, {}, { env })
// Get the access tokens