Skip to content

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

More robust caption update

Chocobozzzda6d0bfe880d
diff --git a/server/core/controllers/api/videos/captions.ts b/server/core/controllers/api/videos/captions.ts
index 1cd6200381..54573d60ee 100644
--- a/server/core/controllers/api/videos/captions.ts
+++ b/server/core/controllers/api/videos/captions.ts
@@ -17,6 +17,7 @@ import {
listVideoCaptionsValidator
} from '../../../middlewares/validators/index.js'
import { VideoCaptionModel } from '../../../models/video/video-caption.js'
+import { retryTransactionWrapper } from '@server/helpers/database-utils.js'
const lTags = loggerTagsFactory('api', 'video-caption')
@@ -39,7 +40,7 @@ videoCaptionsRouter.put('/:videoId/captions/:captionLanguage',
authenticate,
reqVideoCaptionAdd,
asyncMiddleware(addVideoCaptionValidator),
- asyncRetryTransactionMiddleware(createVideoCaption)
+ asyncMiddleware(createVideoCaption)
)
videoCaptionsRouter.delete('/:videoId/captions/:captionLanguage',
@@ -88,8 +89,10 @@ async function createVideoCaption (req: express.Request, res: express.Response)
automaticallyGenerated: false
})
- await sequelizeTypescript.transaction(async t => {
- await federateVideoIfNeeded(video, false, t)
+ await retryTransactionWrapper(() => {
+ return sequelizeTypescript.transaction(async t => {
+ return federateVideoIfNeeded(video, false, t)
+ })
})
Hooks.runAction('action:api.video-caption.created', { caption: videoCaption, req, res })
diff --git a/server/core/lib/video-captions.ts b/server/core/lib/video-captions.ts
index 2309fdc10c..66730de1cc 100644
--- a/server/core/lib/video-captions.ts
+++ b/server/core/lib/video-captions.ts
@@ -19,6 +19,7 @@ import { JobQueue } from './job-queue/job-queue.js'
import { Notifier } from './notifier/notifier.js'
import { TranscriptionJobHandler } from './runners/index.js'
import { VideoPathManager } from './video-path-manager.js'
+import { retryTransactionWrapper } from '@server/helpers/database-utils.js'
const lTags = loggerTagsFactory('video-caption')
@@ -39,8 +40,10 @@ export async function createLocalCaption (options: {
await moveAndProcessCaptionFile({ path }, videoCaption)
- await sequelizeTypescript.transaction(async t => {
- await VideoCaptionModel.insertOrReplaceLanguage(videoCaption, t)
+ await retryTransactionWrapper(() => {
+ return sequelizeTypescript.transaction(t => {
+ return VideoCaptionModel.insertOrReplaceLanguage(videoCaption, t)
+ })
})
return Object.assign(videoCaption, { Video: video })