X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fcustom-validators%2Fvideo-captions.ts;h=0e24655a081a793864a6890c5375bd0cdecd6fed;hb=c56dd2807fe5d129907b9bf8c42656a8314d754b;hp=d5b09ea03628a998a921958bb72fec5c20c572b4;hpb=a2be43f5700460d3afdc194abc788690b79e66cd;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/custom-validators/video-captions.ts b/server/helpers/custom-validators/video-captions.ts index d5b09ea03..0e24655a0 100644 --- a/server/helpers/custom-validators/video-captions.ts +++ b/server/helpers/custom-validators/video-captions.ts @@ -2,6 +2,7 @@ import { UploadFilesForCheck } from 'express' import { readFile } from 'fs-extra' import { getFileSize } from '@shared/extra-utils' import { CONSTRAINTS_FIELDS, MIMETYPES, VIDEO_LANGUAGES } from '../../initializers/constants' +import { logger } from '../logger' import { exists, isFileValid } from './misc' function isVideoCaptionLanguageValid (value: any) { @@ -24,12 +25,13 @@ function isVideoCaptionFile (files: UploadFilesForCheck, field: string) { async function isVTTFileValid (filePath: string) { const size = await getFileSize(filePath) + const content = await readFile(filePath, 'utf8') - if (size > CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) return false + logger.debug('Checking VTT file %s', filePath, { size, content }) - const content = await readFile(filePath, 'utf8') + if (size > CONSTRAINTS_FIELDS.VIDEO_CAPTIONS.CAPTION_FILE.FILE_SIZE.max) return false - return content?.startsWith('WEBVTT\n') + return content?.startsWith('WEBVTT') } // ---------------------------------------------------------------------------