aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/videos/captions.ts10
1 files changed, 2 insertions, 8 deletions
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts
index 05412a17f..4cf8de1ef 100644
--- a/server/controllers/api/videos/captions.ts
+++ b/server/controllers/api/videos/captions.ts
@@ -9,11 +9,10 @@ import { createReqFiles } from '../../../helpers/express-utils'
9import { CONFIG, sequelizeTypescript, VIDEO_CAPTIONS_MIMETYPE_EXT } from '../../../initializers' 9import { CONFIG, sequelizeTypescript, VIDEO_CAPTIONS_MIMETYPE_EXT } from '../../../initializers'
10import { getFormattedObjects } from '../../../helpers/utils' 10import { getFormattedObjects } from '../../../helpers/utils'
11import { VideoCaptionModel } from '../../../models/video/video-caption' 11import { VideoCaptionModel } from '../../../models/video/video-caption'
12import { renamePromise } from '../../../helpers/core-utils'
13import { join } from 'path'
14import { VideoModel } from '../../../models/video/video' 12import { VideoModel } from '../../../models/video/video'
15import { logger } from '../../../helpers/logger' 13import { logger } from '../../../helpers/logger'
16import { federateVideoIfNeeded } from '../../../lib/activitypub' 14import { federateVideoIfNeeded } from '../../../lib/activitypub'
15import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
17 16
18const reqVideoCaptionAdd = createReqFiles( 17const reqVideoCaptionAdd = createReqFiles(
19 [ 'captionfile' ], 18 [ 'captionfile' ],
@@ -66,12 +65,7 @@ async function addVideoCaption (req: express.Request, res: express.Response) {
66 videoCaption.Video = video 65 videoCaption.Video = video
67 66
68 // Move physical file 67 // Move physical file
69 const videoCaptionsDir = CONFIG.STORAGE.CAPTIONS_DIR 68 await moveAndProcessCaptionFile(videoCaptionPhysicalFile, videoCaption)
70 const destination = join(videoCaptionsDir, videoCaption.getCaptionName())
71 await renamePromise(videoCaptionPhysicalFile.path, destination)
72 // This is important in case if there is another attempt in the retry process
73 videoCaptionPhysicalFile.filename = videoCaption.getCaptionName()
74 videoCaptionPhysicalFile.path = destination
75 69
76 await sequelizeTypescript.transaction(async t => { 70 await sequelizeTypescript.transaction(async t => {
77 await VideoCaptionModel.insertOrReplaceLanguage(video.id, req.params.captionLanguage, t) 71 await VideoCaptionModel.insertOrReplaceLanguage(video.id, req.params.captionLanguage, t)