1
0
Fork 0

Fix import video file lock

This commit is contained in:
Chocobozzz 2023-05-02 13:38:00 +02:00 committed by Chocobozzz
parent 94bb740b49
commit 9a3db678f5
7 changed files with 19 additions and 9 deletions

View file

@ -23,7 +23,8 @@ async function processTranscodingJobBuilder (job: Job) {
video,
videoFile,
user
user,
videoFileAlreadyLocked: false
})
}

View file

@ -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 })
}
}

View file

@ -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 })
}
// ---------------------------------------------------------------------------

View file

@ -7,6 +7,7 @@ export function createOptimizeOrMergeAudioJobs (options: {
videoFile: MVideoFile
isNewVideo: boolean
user: MUserId
videoFileAlreadyLocked: boolean
}) {
return getJobBuilder().createOptimizeOrMergeAudioJobs(options)
}

View file

@ -10,6 +10,7 @@ export abstract class AbstractJobBuilder {
videoFile: MVideoFile
isNewVideo: boolean
user: MUserId
videoFileAlreadyLocked: boolean
}): Promise<any>
abstract createTranscodingJobs (options: {

View file

@ -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 => {

View file

@ -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 => {