From a687879e94fa5d3ecdd76bec3d94d0e1698ee913 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 May 2023 13:41:48 +0200 Subject: Reload the video after waiting for the files lock --- server/lib/job-queue/handlers/manage-video-torrent.ts | 3 +++ server/lib/job-queue/handlers/move-to-object-storage.ts | 5 +++-- server/lib/job-queue/handlers/video-live-ending.ts | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'server/lib/job-queue') diff --git a/server/lib/job-queue/handlers/manage-video-torrent.ts b/server/lib/job-queue/handlers/manage-video-torrent.ts index cef93afda..edf52de0c 100644 --- a/server/lib/job-queue/handlers/manage-video-torrent.ts +++ b/server/lib/job-queue/handlers/manage-video-torrent.ts @@ -35,6 +35,9 @@ async function doCreateAction (payload: ManageVideoTorrentPayload & { action: 'c const fileMutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid) try { + await video.reload() + await file.reload() + await createTorrentAndSetInfoHash(video, file) // Refresh videoFile because the createTorrentAndSetInfoHash could be long diff --git a/server/lib/job-queue/handlers/move-to-object-storage.ts b/server/lib/job-queue/handlers/move-to-object-storage.ts index a1530cc57..26752ff37 100644 --- a/server/lib/job-queue/handlers/move-to-object-storage.ts +++ b/server/lib/job-queue/handlers/move-to-object-storage.ts @@ -19,17 +19,18 @@ export async function processMoveToObjectStorage (job: Job) { const payload = job.data as MoveObjectStoragePayload logger.info('Moving video %s in job %s.', payload.videoUUID, job.id) + const fileMutexReleaser = await VideoPathManager.Instance.lockFiles(payload.videoUUID) + const video = await VideoModel.loadWithFiles(payload.videoUUID) // No video, maybe deleted? if (!video) { logger.info('Can\'t process job %d, video does not exist.', job.id, lTagsBase(payload.videoUUID)) + fileMutexReleaser() return undefined } const lTags = lTagsBase(video.uuid, video.url) - const fileMutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid) - try { if (video.VideoFiles) { logger.debug('Moving %d webtorrent files for video %s.', video.VideoFiles.length, video.uuid, lTags) diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 1bf43f592..814f313a3 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts @@ -218,6 +218,7 @@ async function assignReplayFilesToVideo (options: { for (const concatenatedTsFile of concatenatedTsFiles) { const inputFileMutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid) + await video.reload() const concatenatedTsFilePath = join(replayDirectory, concatenatedTsFile) -- cgit v1.2.3