diff options
author | Chocobozzz <me@florianbigard.com> | 2022-06-24 09:34:56 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-06-24 09:35:30 +0200 |
commit | b6e2b5df73d3b67e275000f612907859c39d90d1 (patch) | |
tree | 0a95609e1eaeb33d18bf16d6328d25ed69d6d4d6 /server/lib/live/live-utils.ts | |
parent | f2623febd8b7b818e47d995ae59f4f1d2f37961b (diff) | |
download | PeerTube-b6e2b5df73d3b67e275000f612907859c39d90d1.tar.gz PeerTube-b6e2b5df73d3b67e275000f612907859c39d90d1.tar.zst PeerTube-b6e2b5df73d3b67e275000f612907859c39d90d1.zip |
Fix removed sha segments on fast restream
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) { |