Fix import video file lock
This commit is contained in:
parent
94bb740b49
commit
9a3db678f5
7 changed files with 19 additions and 9 deletions
|
@ -23,7 +23,8 @@ async function processTranscodingJobBuilder (job: Job) {
|
|||
|
||||
video,
|
||||
videoFile,
|
||||
user
|
||||
user,
|
||||
videoFileAlreadyLocked: false
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ async function processFile (downloader: () => Promise<string>, videoImport: MVid
|
|||
})
|
||||
})
|
||||
|
||||
await afterImportSuccess({ videoImport: videoImportUpdated, video, videoFile, user: videoImport.User })
|
||||
await afterImportSuccess({ videoImport: videoImportUpdated, video, videoFile, user: videoImport.User, videoFileAlreadyLocked: true })
|
||||
} finally {
|
||||
videoFileLockReleaser()
|
||||
}
|
||||
|
@ -292,8 +292,9 @@ async function afterImportSuccess (options: {
|
|||
video: MVideoFullLight
|
||||
videoFile: MVideoFile
|
||||
user: MUserId
|
||||
videoFileAlreadyLocked: boolean
|
||||
}) {
|
||||
const { video, videoFile, videoImport, user } = options
|
||||
const { video, videoFile, videoImport, user, videoFileAlreadyLocked } = options
|
||||
|
||||
Notifier.Instance.notifyOnFinishedVideoImport({ videoImport: Object.assign(videoImport, { Video: video }), success: true })
|
||||
|
||||
|
@ -313,7 +314,7 @@ async function afterImportSuccess (options: {
|
|||
}
|
||||
|
||||
if (video.state === VideoState.TO_TRANSCODE) { // Create transcoding jobs?
|
||||
await createOptimizeOrMergeAudioJobs({ video, videoFile, isNewVideo: true, user })
|
||||
await createOptimizeOrMergeAudioJobs({ video, videoFile, isNewVideo: true, user, videoFileAlreadyLocked })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ async function processVideoStudioEdition (job: Job) {
|
|||
|
||||
const user = await UserModel.loadByVideoId(video.id)
|
||||
|
||||
await createOptimizeOrMergeAudioJobs({ video, videoFile: newFile, isNewVideo: false, user })
|
||||
await createOptimizeOrMergeAudioJobs({ video, videoFile: newFile, isNewVideo: false, user, videoFileAlreadyLocked: false })
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -7,6 +7,7 @@ export function createOptimizeOrMergeAudioJobs (options: {
|
|||
videoFile: MVideoFile
|
||||
isNewVideo: boolean
|
||||
user: MUserId
|
||||
videoFileAlreadyLocked: boolean
|
||||
}) {
|
||||
return getJobBuilder().createOptimizeOrMergeAudioJobs(options)
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ export abstract class AbstractJobBuilder {
|
|||
videoFile: MVideoFile
|
||||
isNewVideo: boolean
|
||||
user: MUserId
|
||||
videoFileAlreadyLocked: boolean
|
||||
}): Promise<any>
|
||||
|
||||
abstract createTranscodingJobs (options: {
|
||||
|
|
|
@ -27,13 +27,16 @@ export class TranscodingJobQueueBuilder extends AbstractJobBuilder {
|
|||
videoFile: MVideoFile
|
||||
isNewVideo: boolean
|
||||
user: MUserId
|
||||
videoFileAlreadyLocked: boolean
|
||||
}) {
|
||||
const { video, videoFile, isNewVideo, user } = options
|
||||
const { video, videoFile, isNewVideo, user, videoFileAlreadyLocked } = options
|
||||
|
||||
let mergeOrOptimizePayload: MergeAudioTranscodingPayload | OptimizeTranscodingPayload
|
||||
let nextTranscodingSequentialJobPayloads: (NewWebTorrentResolutionTranscodingPayload | HLSTranscodingPayload)[][] = []
|
||||
|
||||
const mutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid)
|
||||
const mutexReleaser = videoFileAlreadyLocked
|
||||
? () => {}
|
||||
: await VideoPathManager.Instance.lockFiles(video.uuid)
|
||||
|
||||
try {
|
||||
await VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(video), async videoFilePath => {
|
||||
|
|
|
@ -26,10 +26,13 @@ export class TranscodingRunnerJobBuilder extends AbstractJobBuilder {
|
|||
videoFile: MVideoFile
|
||||
isNewVideo: boolean
|
||||
user: MUserId
|
||||
videoFileAlreadyLocked: boolean
|
||||
}) {
|
||||
const { video, videoFile, isNewVideo, user } = options
|
||||
const { video, videoFile, isNewVideo, user, videoFileAlreadyLocked } = options
|
||||
|
||||
const mutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid)
|
||||
const mutexReleaser = videoFileAlreadyLocked
|
||||
? () => {}
|
||||
: await VideoPathManager.Instance.lockFiles(video.uuid)
|
||||
|
||||
try {
|
||||
await VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(video), async videoFilePath => {
|
||||
|
|
Loading…
Reference in a new issue