diff options
Diffstat (limited to 'server/lib/live/live-utils.ts')
-rw-r--r-- | server/lib/live/live-utils.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/server/lib/live/live-utils.ts b/server/lib/live/live-utils.ts index 6305a97a8..bba876642 100644 --- a/server/lib/live/live-utils.ts +++ b/server/lib/live/live-utils.ts | |||
@@ -3,6 +3,7 @@ import { basename, join } from 'path' | |||
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { MStreamingPlaylist, MVideo } from '@server/types/models' | 4 | import { MStreamingPlaylist, MVideo } from '@server/types/models' |
5 | import { getLiveDirectory } from '../paths' | 5 | import { getLiveDirectory } from '../paths' |
6 | import { LiveSegmentShaStore } from './live-segment-sha-store' | ||
6 | 7 | ||
7 | function buildConcatenatedName (segmentOrPlaylistPath: string) { | 8 | function buildConcatenatedName (segmentOrPlaylistPath: string) { |
8 | const num = basename(segmentOrPlaylistPath).match(/^(\d+)(-|\.)/) | 9 | const num = basename(segmentOrPlaylistPath).match(/^(\d+)(-|\.)/) |
@@ -11,9 +12,7 @@ function buildConcatenatedName (segmentOrPlaylistPath: string) { | |||
11 | } | 12 | } |
12 | 13 | ||
13 | async function cleanupPermanentLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) { | 14 | async function cleanupPermanentLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) { |
14 | const hlsDirectory = getLiveDirectory(video) | 15 | await cleanupTMPLiveFiles(video) |
15 | |||
16 | await cleanupTMPLiveFiles(hlsDirectory) | ||
17 | 16 | ||
18 | await streamingPlaylist.destroy() | 17 | await streamingPlaylist.destroy() |
19 | } | 18 | } |
@@ -24,11 +23,19 @@ async function cleanupUnsavedNormalLive (video: MVideo, streamingPlaylist: MStre | |||
24 | await remove(hlsDirectory) | 23 | await remove(hlsDirectory) |
25 | 24 | ||
26 | await streamingPlaylist.destroy() | 25 | await streamingPlaylist.destroy() |
26 | |||
27 | LiveSegmentShaStore.Instance.cleanupShaSegments(video.uuid) | ||
27 | } | 28 | } |
28 | 29 | ||
29 | async function cleanupTMPLiveFiles (hlsDirectory: string) { | 30 | async function cleanupTMPLiveFiles (video: MVideo) { |
31 | const hlsDirectory = getLiveDirectory(video) | ||
32 | |||
33 | LiveSegmentShaStore.Instance.cleanupShaSegments(video.uuid) | ||
34 | |||
30 | if (!await pathExists(hlsDirectory)) return | 35 | if (!await pathExists(hlsDirectory)) return |
31 | 36 | ||
37 | logger.info('Cleanup TMP live files of %s.', hlsDirectory) | ||
38 | |||
32 | const files = await readdir(hlsDirectory) | 39 | const files = await readdir(hlsDirectory) |
33 | 40 | ||
34 | for (const filename of files) { | 41 | for (const filename of files) { |