+
+export const runnerJobGetVideoStudioTaskFileValidator = [
+ param('filename').custom(v => isSafeFilename(v)),
+
+ (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ if (areValidationErrors(req, res)) return
+
+ const filename = req.params.filename
+
+ const payload = res.locals.runnerJob.payload as RunnerJobVideoEditionTranscodingPayload
+
+ const found = Array.isArray(payload?.tasks) && payload.tasks.some(t => {
+ if (hasVideoStudioTaskFile(t)) {
+ return basename(t.options.file) === filename
+ }
+
+ return false
+ })
+
+ if (!found) {
+ return res.fail({
+ status: HttpStatusCode.BAD_REQUEST_400,
+ message: 'File is not associated to this edition task',
+ tags: [ ...tags, res.locals.videoAll.uuid ]
+ })
+ }
+
+ return next()
+ }
+]