diff options
Diffstat (limited to 'server/lib/job-queue')
5 files changed, 20 insertions, 28 deletions
diff --git a/server/lib/job-queue/handlers/activitypub-cleaner.ts b/server/lib/job-queue/handlers/activitypub-cleaner.ts index 1caca1dcc..56e2b0ceb 100644 --- a/server/lib/job-queue/handlers/activitypub-cleaner.ts +++ b/server/lib/job-queue/handlers/activitypub-cleaner.ts | |||
@@ -12,7 +12,7 @@ import { AP_CLEANER_CONCURRENCY } from '@server/initializers/constants' | |||
12 | import { VideoModel } from '@server/models/video/video' | 12 | import { VideoModel } from '@server/models/video/video' |
13 | import { VideoCommentModel } from '@server/models/video/video-comment' | 13 | import { VideoCommentModel } from '@server/models/video/video-comment' |
14 | import { VideoShareModel } from '@server/models/video/video-share' | 14 | import { VideoShareModel } from '@server/models/video/video-share' |
15 | import { HttpStatusCode } from '@shared/core-utils' | 15 | import { HttpStatusCode } from '@shared/models' |
16 | import { logger } from '../../../helpers/logger' | 16 | import { logger } from '../../../helpers/logger' |
17 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 17 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
18 | 18 | ||
diff --git a/server/lib/job-queue/handlers/video-file-import.ts b/server/lib/job-queue/handlers/video-file-import.ts index 187cb652e..4d199f247 100644 --- a/server/lib/job-queue/handlers/video-file-import.ts +++ b/server/lib/job-queue/handlers/video-file-import.ts | |||
@@ -2,7 +2,7 @@ import * as Bull from 'bull' | |||
2 | import { copy, stat } from 'fs-extra' | 2 | import { copy, stat } from 'fs-extra' |
3 | import { getLowercaseExtension } from '@server/helpers/core-utils' | 3 | import { getLowercaseExtension } from '@server/helpers/core-utils' |
4 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' | 4 | import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent' |
5 | import { generateVideoFilename, getVideoFilePath } from '@server/lib/video-paths' | 5 | import { generateWebTorrentVideoFilename, getVideoFilePath } from '@server/lib/video-paths' |
6 | import { UserModel } from '@server/models/user/user' | 6 | import { UserModel } from '@server/models/user/user' |
7 | import { MVideoFullLight } from '@server/types/models' | 7 | import { MVideoFullLight } from '@server/types/models' |
8 | import { VideoFileImportPayload } from '@shared/models' | 8 | import { VideoFileImportPayload } from '@shared/models' |
@@ -61,8 +61,7 @@ async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) { | |||
61 | 61 | ||
62 | if (currentVideoFile) { | 62 | if (currentVideoFile) { |
63 | // Remove old file and old torrent | 63 | // Remove old file and old torrent |
64 | await video.removeFile(currentVideoFile) | 64 | await video.removeFileAndTorrent(currentVideoFile) |
65 | await currentVideoFile.removeTorrent() | ||
66 | // Remove the old video file from the array | 65 | // Remove the old video file from the array |
67 | video.VideoFiles = video.VideoFiles.filter(f => f !== currentVideoFile) | 66 | video.VideoFiles = video.VideoFiles.filter(f => f !== currentVideoFile) |
68 | 67 | ||
@@ -72,7 +71,7 @@ async function updateVideoFile (video: MVideoFullLight, inputFilePath: string) { | |||
72 | const newVideoFile = new VideoFileModel({ | 71 | const newVideoFile = new VideoFileModel({ |
73 | resolution: videoFileResolution, | 72 | resolution: videoFileResolution, |
74 | extname: fileExt, | 73 | extname: fileExt, |
75 | filename: generateVideoFilename(video, false, videoFileResolution, fileExt), | 74 | filename: generateWebTorrentVideoFilename(videoFileResolution, fileExt), |
76 | size, | 75 | size, |
77 | fps, | 76 | fps, |
78 | videoId: video.id | 77 | videoId: video.id |
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 55498003d..5fd2039b1 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -8,7 +8,7 @@ import { Hooks } from '@server/lib/plugins/hooks' | |||
8 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 8 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
9 | import { isAbleToUploadVideo } from '@server/lib/user' | 9 | import { isAbleToUploadVideo } from '@server/lib/user' |
10 | import { addOptimizeOrMergeAudioJob } from '@server/lib/video' | 10 | import { addOptimizeOrMergeAudioJob } from '@server/lib/video' |
11 | import { generateVideoFilename, getVideoFilePath } from '@server/lib/video-paths' | 11 | import { generateWebTorrentVideoFilename, getVideoFilePath } from '@server/lib/video-paths' |
12 | import { ThumbnailModel } from '@server/models/video/thumbnail' | 12 | import { ThumbnailModel } from '@server/models/video/thumbnail' |
13 | import { MVideoImportDefault, MVideoImportDefaultFiles, MVideoImportVideo } from '@server/types/models/video/video-import' | 13 | import { MVideoImportDefault, MVideoImportDefaultFiles, MVideoImportVideo } from '@server/types/models/video/video-import' |
14 | import { | 14 | import { |
@@ -124,7 +124,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid | |||
124 | extname: fileExt, | 124 | extname: fileExt, |
125 | resolution: videoFileResolution, | 125 | resolution: videoFileResolution, |
126 | size: stats.size, | 126 | size: stats.size, |
127 | filename: generateVideoFilename(videoImport.Video, false, videoFileResolution, fileExt), | 127 | filename: generateWebTorrentVideoFilename(videoFileResolution, fileExt), |
128 | fps, | 128 | fps, |
129 | videoId: videoImport.videoId | 129 | videoId: videoImport.videoId |
130 | } | 130 | } |
@@ -235,7 +235,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid | |||
235 | }) | 235 | }) |
236 | }) | 236 | }) |
237 | 237 | ||
238 | Notifier.Instance.notifyOnFinishedVideoImport(videoImportUpdated, true) | 238 | Notifier.Instance.notifyOnFinishedVideoImport({ videoImport: videoImportUpdated, success: true }) |
239 | 239 | ||
240 | if (video.isBlacklisted()) { | 240 | if (video.isBlacklisted()) { |
241 | const videoBlacklist = Object.assign(video.VideoBlacklist, { Video: video }) | 241 | const videoBlacklist = Object.assign(video.VideoBlacklist, { Video: video }) |
@@ -263,7 +263,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid | |||
263 | } | 263 | } |
264 | await videoImport.save() | 264 | await videoImport.save() |
265 | 265 | ||
266 | Notifier.Instance.notifyOnFinishedVideoImport(videoImport, false) | 266 | Notifier.Instance.notifyOnFinishedVideoImport({ videoImport, success: false }) |
267 | 267 | ||
268 | throw err | 268 | throw err |
269 | } | 269 | } |
diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 9eba41bf8..386ccdc7b 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts | |||
@@ -7,12 +7,12 @@ import { buildConcatenatedName, cleanupLive, LiveSegmentShaStore } from '@server | |||
7 | import { generateVideoMiniature } from '@server/lib/thumbnail' | 7 | import { generateVideoMiniature } from '@server/lib/thumbnail' |
8 | import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/video-transcoding' | 8 | import { generateHlsPlaylistResolutionFromTS } from '@server/lib/transcoding/video-transcoding' |
9 | import { publishAndFederateIfNeeded } from '@server/lib/video' | 9 | import { publishAndFederateIfNeeded } from '@server/lib/video' |
10 | import { getHLSDirectory } from '@server/lib/video-paths' | 10 | import { generateHLSMasterPlaylistFilename, generateHlsSha256SegmentsFilename, getHLSDirectory } from '@server/lib/video-paths' |
11 | import { VideoModel } from '@server/models/video/video' | 11 | import { VideoModel } from '@server/models/video/video' |
12 | import { VideoFileModel } from '@server/models/video/video-file' | 12 | import { VideoFileModel } from '@server/models/video/video-file' |
13 | import { VideoLiveModel } from '@server/models/video/video-live' | 13 | import { VideoLiveModel } from '@server/models/video/video-live' |
14 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' | 14 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' |
15 | import { MVideo, MVideoLive } from '@server/types/models' | 15 | import { MStreamingPlaylist, MVideo, MVideoLive } from '@server/types/models' |
16 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' | 16 | import { ThumbnailType, VideoLiveEndingPayload, VideoState } from '@shared/models' |
17 | import { logger } from '../../../helpers/logger' | 17 | import { logger } from '../../../helpers/logger' |
18 | 18 | ||
@@ -43,7 +43,7 @@ async function processVideoLiveEnding (job: Bull.Job) { | |||
43 | return cleanupLive(video, streamingPlaylist) | 43 | return cleanupLive(video, streamingPlaylist) |
44 | } | 44 | } |
45 | 45 | ||
46 | return saveLive(video, live) | 46 | return saveLive(video, live, streamingPlaylist) |
47 | } | 47 | } |
48 | 48 | ||
49 | // --------------------------------------------------------------------------- | 49 | // --------------------------------------------------------------------------- |
@@ -54,14 +54,14 @@ export { | |||
54 | 54 | ||
55 | // --------------------------------------------------------------------------- | 55 | // --------------------------------------------------------------------------- |
56 | 56 | ||
57 | async function saveLive (video: MVideo, live: MVideoLive) { | 57 | async function saveLive (video: MVideo, live: MVideoLive, streamingPlaylist: MStreamingPlaylist) { |
58 | const hlsDirectory = getHLSDirectory(video, false) | 58 | const hlsDirectory = getHLSDirectory(video, false) |
59 | const replayDirectory = join(hlsDirectory, VIDEO_LIVE.REPLAY_DIRECTORY) | 59 | const replayDirectory = join(hlsDirectory, VIDEO_LIVE.REPLAY_DIRECTORY) |
60 | 60 | ||
61 | const rootFiles = await readdir(hlsDirectory) | 61 | const rootFiles = await readdir(hlsDirectory) |
62 | 62 | ||
63 | const playlistFiles = rootFiles.filter(file => { | 63 | const playlistFiles = rootFiles.filter(file => { |
64 | return file.endsWith('.m3u8') && file !== 'master.m3u8' | 64 | return file.endsWith('.m3u8') && file !== streamingPlaylist.playlistFilename |
65 | }) | 65 | }) |
66 | 66 | ||
67 | await cleanupLiveFiles(hlsDirectory) | 67 | await cleanupLiveFiles(hlsDirectory) |
@@ -80,7 +80,12 @@ async function saveLive (video: MVideo, live: MVideoLive) { | |||
80 | 80 | ||
81 | const hlsPlaylist = videoWithFiles.getHLSPlaylist() | 81 | const hlsPlaylist = videoWithFiles.getHLSPlaylist() |
82 | await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id) | 82 | await VideoFileModel.removeHLSFilesOfVideoId(hlsPlaylist.id) |
83 | |||
84 | // Reset playlist | ||
83 | hlsPlaylist.VideoFiles = [] | 85 | hlsPlaylist.VideoFiles = [] |
86 | hlsPlaylist.playlistFilename = generateHLSMasterPlaylistFilename() | ||
87 | hlsPlaylist.segmentsSha256Filename = generateHlsSha256SegmentsFilename() | ||
88 | await hlsPlaylist.save() | ||
84 | 89 | ||
85 | let durationDone = false | 90 | let durationDone = false |
86 | 91 | ||
diff --git a/server/lib/job-queue/handlers/video-transcoding.ts b/server/lib/job-queue/handlers/video-transcoding.ts index f5ba6f435..2abb351ce 100644 --- a/server/lib/job-queue/handlers/video-transcoding.ts +++ b/server/lib/job-queue/handlers/video-transcoding.ts | |||
@@ -28,21 +28,10 @@ import { JobQueue } from '../job-queue' | |||
28 | 28 | ||
29 | type HandlerFunction = (job: Bull.Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<any> | 29 | type HandlerFunction = (job: Bull.Job, payload: VideoTranscodingPayload, video: MVideoFullLight, user: MUser) => Promise<any> |
30 | 30 | ||
31 | const handlers: { [ id: string ]: HandlerFunction } = { | 31 | const handlers: { [ id in VideoTranscodingPayload['type'] ]: HandlerFunction } = { |
32 | // Deprecated, introduced in 3.1 | ||
33 | 'hls': handleHLSJob, | ||
34 | 'new-resolution-to-hls': handleHLSJob, | 32 | 'new-resolution-to-hls': handleHLSJob, |
35 | |||
36 | // Deprecated, introduced in 3.1 | ||
37 | 'new-resolution': handleNewWebTorrentResolutionJob, | ||
38 | 'new-resolution-to-webtorrent': handleNewWebTorrentResolutionJob, | 33 | 'new-resolution-to-webtorrent': handleNewWebTorrentResolutionJob, |
39 | |||
40 | // Deprecated, introduced in 3.1 | ||
41 | 'merge-audio': handleWebTorrentMergeAudioJob, | ||
42 | 'merge-audio-to-webtorrent': handleWebTorrentMergeAudioJob, | 34 | 'merge-audio-to-webtorrent': handleWebTorrentMergeAudioJob, |
43 | |||
44 | // Deprecated, introduced in 3.1 | ||
45 | 'optimize': handleWebTorrentOptimizeJob, | ||
46 | 'optimize-to-webtorrent': handleWebTorrentOptimizeJob | 35 | 'optimize-to-webtorrent': handleWebTorrentOptimizeJob |
47 | } | 36 | } |
48 | 37 | ||
@@ -125,8 +114,7 @@ async function onHlsPlaylistGeneration (video: MVideoFullLight, user: MUser, pay | |||
125 | if (payload.isMaxQuality && CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) { | 114 | if (payload.isMaxQuality && CONFIG.TRANSCODING.WEBTORRENT.ENABLED === false) { |
126 | // Remove webtorrent files if not enabled | 115 | // Remove webtorrent files if not enabled |
127 | for (const file of video.VideoFiles) { | 116 | for (const file of video.VideoFiles) { |
128 | await video.removeFile(file) | 117 | await video.removeFileAndTorrent(file) |
129 | await file.removeTorrent() | ||
130 | await file.destroy() | 118 | await file.destroy() |
131 | } | 119 | } |
132 | 120 | ||