From aa887096f9a305568dc3a846d0c9cdf7e45f1c67 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 25 Oct 2022 14:18:59 +0200 Subject: Correctly delete live files from object storage --- server/tests/shared/live.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'server/tests/shared') diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts index 78e29f575..47e0dc481 100644 --- a/server/tests/shared/live.ts +++ b/server/tests/shared/live.ts @@ -7,10 +7,25 @@ import { LiveVideo, VideoStreamingPlaylistType } from '@shared/models' import { ObjectStorageCommand, PeerTubeServer } from '@shared/server-commands' import { checkLiveSegmentHash, checkResolutionsInMasterPlaylist } from './streaming-playlists' -async function checkLiveCleanup (server: PeerTubeServer, videoUUID: string, savedResolutions: number[] = []) { +async function checkLiveCleanup (options: { + server: PeerTubeServer + videoUUID: string + permanent: boolean + savedResolutions?: number[] +}) { + const { server, videoUUID, permanent, savedResolutions = [] } = options + const basePath = server.servers.buildDirectory('streaming-playlists') const hlsPath = join(basePath, 'hls', videoUUID) + if (permanent) { + if (!await pathExists(hlsPath)) return + + const files = await readdir(hlsPath) + expect(files).to.have.lengthOf(0) + return + } + if (savedResolutions.length === 0) { return checkUnsavedLiveCleanup(server, videoUUID, hlsPath) } -- cgit v1.2.3