1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Fix video upload with a capitalized ext

This commit is contained in:
Chocobozzz 2021-06-08 09:33:03 +02:00
parent 2951065162
commit ea54cd04c1
No known key found for this signature in database
GPG key ID: 583A612D890159BE
10 changed files with 82 additions and 49 deletions

View file

@ -1,7 +1,7 @@
import { copy, readFile, remove, rename } from 'fs-extra'
import * as Jimp from 'jimp'
import { extname } from 'path'
import { v4 as uuidv4 } from 'uuid'
import { getLowercaseExtension } from './core-utils'
import { convertWebPToJPG, processGIF } from './ffmpeg-utils'
import { logger } from './logger'
@ -15,7 +15,7 @@ async function processImage (
newSize: { width: number, height: number },
keepOriginal = false
) {
const extension = extname(path)
const extension = getLowercaseExtension(path)
if (path === destination) {
throw new Error('Jimp/FFmpeg needs an input path different that the output path.')
@ -61,7 +61,8 @@ async function jimpProcessor (path: string, destination: string, newSize: { widt
await remove(destination)
// Optimization if the source file has the appropriate size
if (await skipProcessing({ jimpInstance, newSize, imageBytes: inputBuffer.byteLength, inputExt, outputExt: extname(destination) })) {
const outputExt = getLowercaseExtension(destination)
if (skipProcessing({ jimpInstance, newSize, imageBytes: inputBuffer.byteLength, inputExt, outputExt })) {
return copy(path, destination)
}