]>
Commit | Line | Data |
---|---|---|
c55e3d72 C |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
3 | import { expect } from 'chai' | |
4 | import { pathExists, readdir } from 'fs-extra' | |
5 | import { join } from 'path' | |
6 | import { PeerTubeServer } from '@shared/server-commands' | |
7 | ||
4ec52d04 | 8 | async function checkLiveCleanup (server: PeerTubeServer, videoUUID: string, savedResolutions: number[] = []) { |
c55e3d72 C |
9 | const basePath = server.servers.buildDirectory('streaming-playlists') |
10 | const hlsPath = join(basePath, 'hls', videoUUID) | |
11 | ||
4ec52d04 | 12 | if (savedResolutions.length === 0) { |
c55e3d72 C |
13 | const result = await pathExists(hlsPath) |
14 | expect(result).to.be.false | |
15 | ||
16 | return | |
17 | } | |
18 | ||
19 | const files = await readdir(hlsPath) | |
20 | ||
21 | // fragmented file and playlist per resolution + master playlist + segments sha256 json file | |
4ec52d04 | 22 | expect(files).to.have.lengthOf(savedResolutions.length * 2 + 2) |
c55e3d72 | 23 | |
4ec52d04 | 24 | for (const resolution of savedResolutions) { |
c55e3d72 C |
25 | const fragmentedFile = files.find(f => f.endsWith(`-${resolution}-fragmented.mp4`)) |
26 | expect(fragmentedFile).to.exist | |
27 | ||
28 | const playlistFile = files.find(f => f.endsWith(`${resolution}.m3u8`)) | |
29 | expect(playlistFile).to.exist | |
30 | } | |
31 | ||
32 | const masterPlaylistFile = files.find(f => f.endsWith('-master.m3u8')) | |
33 | expect(masterPlaylistFile).to.exist | |
34 | ||
35 | const shaFile = files.find(f => f.endsWith('-segments-sha256.json')) | |
36 | expect(shaFile).to.exist | |
37 | } | |
38 | ||
39 | export { | |
4ec52d04 | 40 | checkLiveCleanup |
c55e3d72 | 41 | } |