]>
Commit | Line | Data |
---|---|---|
6c5065a0 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' | |
5e47f6ab C |
5 | import { homedir } from 'os' |
6 | import { join } from 'path' | |
c55e3d72 | 7 | import { PeerTubeServer } from '@shared/server-commands' |
cfa61763 | 8 | import { PeerTubeRunnerProcess } from './peertube-runner-process' |
6c5065a0 | 9 | |
5e47f6ab | 10 | export async function checkTmpIsEmpty (server: PeerTubeServer) { |
6c5065a0 C |
11 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) |
12 | ||
6c5f0d3a | 13 | if (await pathExists(server.getDirectoryPath('tmp/hls'))) { |
6c5065a0 C |
14 | await checkDirectoryIsEmpty(server, 'tmp/hls') |
15 | } | |
16 | } | |
17 | ||
5e47f6ab | 18 | export async function checkPersistentTmpIsEmpty (server: PeerTubeServer) { |
6a490560 C |
19 | await checkDirectoryIsEmpty(server, 'tmp-persistent') |
20 | } | |
21 | ||
5e47f6ab | 22 | export async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, exceptions: string[] = []) { |
6c5f0d3a | 23 | const directoryPath = server.getDirectoryPath(directory) |
6c5065a0 C |
24 | |
25 | const directoryExists = await pathExists(directoryPath) | |
26 | expect(directoryExists).to.be.true | |
27 | ||
28 | const files = await readdir(directoryPath) | |
29 | const filtered = files.filter(f => exceptions.includes(f) === false) | |
30 | ||
31 | expect(filtered).to.have.lengthOf(0) | |
32 | } | |
33 | ||
cfa61763 C |
34 | export async function checkPeerTubeRunnerCacheIsEmpty (runner: PeerTubeRunnerProcess) { |
35 | const directoryPath = join(homedir(), '.cache', 'peertube-runner-nodejs', runner.getId(), 'transcoding') | |
5e47f6ab C |
36 | |
37 | const directoryExists = await pathExists(directoryPath) | |
38 | expect(directoryExists).to.be.true | |
39 | ||
40 | const files = await readdir(directoryPath) | |
41 | ||
33b91e53 | 42 | expect(files, 'Directory content: ' + files.join(', ')).to.have.lengthOf(0) |
6c5065a0 | 43 | } |