Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix missing mutex for captions

Chocobozzz32ba4231c0fe
diff --git a/server/core/lib/schedulers/update-videos-scheduler.ts b/server/core/lib/schedulers/update-videos-scheduler.ts
index d35dd96808..bb7a48887d 100644
--- a/server/core/lib/schedulers/update-videos-scheduler.ts
+++ b/server/core/lib/schedulers/update-videos-scheduler.ts
@@ -46,9 +46,9 @@ export class UpdateVideosScheduler extends AbstractScheduler {
if (published) Notifier.Instance.notifyOnVideoPublishedAfterScheduledUpdate(video)
} catch (err) {
logger.error('Cannot update video ' + videoOnly.uuid, { err, ...lTags(videoOnly.uuid) })
+ } finally {
+ mutexReleaser()
}
-
- mutexReleaser()
}
}
diff --git a/server/core/lib/video-captions.ts b/server/core/lib/video-captions.ts
index 08a4af675d..ea8c760aae 100644
--- a/server/core/lib/video-captions.ts
+++ b/server/core/lib/video-captions.ts
@@ -233,38 +233,45 @@ export async function onTranscriptionEnded (options: {
return
}
- if (!video.language) {
- video.language = language
- await video.save()
- }
+ const videoFileMutexReleaser = await VideoPathManager.Instance.lockFiles(video.uuid)
- const existing = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
- if (existing && !existing.automaticallyGenerated) {
- logger.info(
- // oxlint-disable-next-line max-len
- `Do not replace existing caption for video ${video.uuid} after transcription (subtitle may have been added while during the transcription process)`,
- lTags(video.uuid)
- )
- return
- }
+ try {
+ if (!video.language) {
+ video.language = language
+ await video.save()
+ }
- const caption = await createLocalCaption({
- video,
- language,
- path: vttPath,
- automaticallyGenerated: true
- })
+ const existing = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
+
+ if (existing && !existing.automaticallyGenerated) {
+ logger.info(
+ // oxlint-disable-next-line max-len
+ `Do not replace existing caption for video ${video.uuid} after transcription (subtitle may have been added while during the transcription process)`,
+ lTags(video.uuid)
+ )
+ return
+ }
+
+ const caption = await createLocalCaption({
+ video,
+ language,
+ path: vttPath,
+ automaticallyGenerated: true
+ })
- if (caption.m3u8Filename) {
- await updateHLSMasterOnCaptionChangeIfNeeded(video)
+ if (caption.m3u8Filename) {
+ await updateHLSMasterOnCaptionChangeIfNeeded(video)
+ }
+
+ Notifier.Instance.notifyOfGeneratedVideoTranscription(caption)
+ } finally {
+ videoFileMutexReleaser()
}
await sequelizeTypescript.transaction(async t => {
await federateVideoIfNeeded(video, false, t)
})
- Notifier.Instance.notifyOfGeneratedVideoTranscription(caption)
-
logger.info(`Transcription ended for ${video.uuid}`, lTags(video.uuid, ...customLTags))
}