diff options
7 files changed, 19 insertions, 9 deletions
diff --git a/server/lib/job-queue/handlers/transcoding-job-builder.ts b/server/lib/job-queue/handlers/transcoding-job-builder.ts index cb45337df..8621b109f 100644 --- a/server/lib/job-queue/handlers/transcoding-job-builder.ts +++ b/server/lib/job-queue/handlers/transcoding-job-builder.ts | |||
@@ -23,7 +23,8 @@ async function processTranscodingJobBuilder (job: Job) { | |||
23 | 23 | ||
24 | video, | 24 | video, |
25 | videoFile, | 25 | videoFile, |
26 | user | 26 | user, |
27 | videoFileAlreadyLocked: false | ||
27 | }) | 28 | }) |
28 | } | 29 | } |
29 | 30 | ||
diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 2a063282c..cdd362f6e 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts | |||
@@ -242,7 +242,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid | |||
242 | }) | 242 | }) |
243 | }) | 243 | }) |
244 | 244 | ||
245 | await afterImportSuccess({ videoImport: videoImportUpdated, video, videoFile, user: videoImport.User }) | 245 | await afterImportSuccess({ videoImport: videoImportUpdated, video, videoFile, user: videoImport.User, videoFileAlreadyLocked: true }) |
246 | } finally { | 246 | } finally { |
247 | videoFileLockReleaser() | 247 | videoFileLockReleaser() |
248 | } | 248 | } |
@@ -292,8 +292,9 @@ async function afterImportSuccess (options: { | |||
292 | video: MVideoFullLight | 292 | video: MVideoFullLight |
293 | videoFile: MVideoFile | 293 | videoFile: MVideoFile |
294 | user: MUserId | 294 | user: MUserId |
295 | videoFileAlreadyLocked: boolean | ||
295 | }) { | 296 | }) { |
296 | const { video, videoFile, videoImport, user } = options | 297 | const { video, videoFile, videoImport, user, videoFileAlreadyLocked } = options |
297 | 298 | ||
298 | Notifier.Instance.notifyOnFinishedVideoImport({ videoImport: Object.assign(videoImport, { Video: video }), success: true }) | 299 | Notifier.Instance.notifyOnFinishedVideoImport({ videoImport: Object.assign(videoImport, { Video: video }), success: true }) |
299 | 300 | ||
@@ -313,7 +314,7 @@ async function afterImportSuccess (options: { | |||
313 | } | 314 | } |
314 | 315 | ||
315 | if (video.state === VideoState.TO_TRANSCODE) { // Create transcoding jobs? | 316 | if (video.state === VideoState.TO_TRANSCODE) { // Create transcoding jobs? |
316 | await createOptimizeOrMergeAudioJobs({ video, videoFile, isNewVideo: true, user }) | 317 | await createOptimizeOrMergeAudioJobs({ video, videoFile, isNewVideo: true, user, videoFileAlreadyLocked }) |
317 | } | 318 | } |
318 | } | 319 | } |
319 | 320 | ||
diff --git a/server/lib/job-queue/handlers/video-studio-edition.ts b/server/lib/job-queue/handlers/video-studio-edition.ts index 991d11ef1..fbb55a388 100644 --- a/server/lib/job-queue/handlers/video-studio-edition.ts +++ b/server/lib/job-queue/handlers/video-studio-edition.ts | |||
@@ -95,7 +95,7 @@ async function processVideoStudioEdition (job: Job) { | |||
95 | 95 | ||
96 | const user = await UserModel.loadByVideoId(video.id) | 96 | const user = await UserModel.loadByVideoId(video.id) |
97 | 97 | ||
98 | await createOptimizeOrMergeAudioJobs({ video, videoFile: newFile, isNewVideo: false, user }) | 98 | await createOptimizeOrMergeAudioJobs({ video, videoFile: newFile, isNewVideo: false, user, videoFileAlreadyLocked: false }) |
99 | } | 99 | } |
100 | 100 | ||
101 | // --------------------------------------------------------------------------- | 101 | // --------------------------------------------------------------------------- |
diff --git a/server/lib/transcoding/create-transcoding-job.ts b/server/lib/transcoding/create-transcoding-job.ts index 46831a912..abe32684d 100644 --- a/server/lib/transcoding/create-transcoding-job.ts +++ b/server/lib/transcoding/create-transcoding-job.ts | |||
@@ -7,6 +7,7 @@ export function createOptimizeOrMergeAudioJobs (options: { | |||
7 | videoFile: MVideoFile | 7 | videoFile: MVideoFile |
8 | isNewVideo: boolean | 8 | isNewVideo: boolean |
9 | user: MUserId | 9 | user: MUserId |
10 | videoFileAlreadyLocked: boolean | ||
10 | }) { | 11 | }) { |
11 | return getJobBuilder().createOptimizeOrMergeAudioJobs(options) | 12 | return getJobBuilder().createOptimizeOrMergeAudioJobs(options) |
12 | } | 13 | } |
diff --git a/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts b/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts index f1e9efdcf..576e786d5 100644 --- a/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts +++ b/server/lib/transcoding/shared/job-builders/abstract-job-builder.ts | |||
@@ -10,6 +10,7 @@ export abstract class AbstractJobBuilder { | |||
10 | videoFile: MVideoFile | 10 | videoFile: MVideoFile |
11 | isNewVideo: boolean | 11 | isNewVideo: boolean |
12 | user: MUserId | 12 | user: MUserId |
13 | videoFileAlreadyLocked: boolean | ||
13 | }): Promise<any> | 14 | }): Promise<any> |
14 | 15 | ||
15 | abstract createTranscodingJobs (options: { | 16 | abstract createTranscodingJobs (options: { |
diff --git a/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts b/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts index c09c6b8ce..5a9c93ee5 100644 --- a/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts +++ b/server/lib/transcoding/shared/job-builders/transcoding-job-queue-builder.ts | |||
@@ -27,13 +27,16 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder { | |||
27 | videoFile: MVideoFile | 27 | videoFile: MVideoFile |
28 | isNewVideo: boolean | 28 | isNewVideo: boolean |
29 | user: MUserId | 29 | user: MUserId |
30 | videoFileAlreadyLocked: boolean | ||
30 | }) { | 31 | }) { |
31 | const { video, videoFile, isNewVideo, user } = options | 32 | const { video, videoFile, isNewVideo, user, videoFileAlreadyLocked } = options |
32 | 33 | ||
33 | let mergeOrOptimizePayload: MergeAudioTranscodingPayload | OptimizeTranscodingPayload | 34 | let mergeOrOptimizePayload: MergeAudioTranscodingPayload | OptimizeTranscodingPayload |
34 | let nextTranscodingSequentialJobPayloads: (NewWebTorrentResolutionTranscodingPayload | HLSTranscodingPayload)[][] = [] | 35 | let nextTranscodingSequentialJobPayloads: (NewWebTorrentResolutionTranscodingPayload | HLSTranscodingPayload)[][] = [] |
35 | 36 | ||
36 | const mutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid) | 37 | const mutexReleaser = videoFileAlreadyLocked |
38 | ? () => {} | ||
39 | : await VideoPathManager.Instance.lockFiles(video.uuid) | ||
37 | 40 | ||
38 | try { | 41 | try { |
39 | await VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(video), async videoFilePath => { | 42 | await VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(video), async videoFilePath => { |
diff --git a/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts b/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts index c7a63d2e2..274dce21b 100644 --- a/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts +++ b/server/lib/transcoding/shared/job-builders/transcoding-runner-job-builder.ts | |||
@@ -26,10 +26,13 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder { | |||
26 | videoFile: MVideoFile | 26 | videoFile: MVideoFile |
27 | isNewVideo: boolean | 27 | isNewVideo: boolean |
28 | user: MUserId | 28 | user: MUserId |
29 | videoFileAlreadyLocked: boolean | ||
29 | }) { | 30 | }) { |
30 | const { video, videoFile, isNewVideo, user } = options | 31 | const { video, videoFile, isNewVideo, user, videoFileAlreadyLocked } = options |
31 | 32 | ||
32 | const mutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid) | 33 | const mutexReleaser = videoFileAlreadyLocked |
34 | ? () => {} | ||
35 | : await VideoPathManager.Instance.lockFiles(video.uuid) | ||
33 | 36 | ||
34 | try { | 37 | try { |
35 | await VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(video), async videoFilePath => { | 38 | await VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(video), async videoFilePath => { |