import * as multer from 'multer'
import { REMOTE_SCHEME } from '../initializers/constants'
import { logger } from './logger'
-import { deleteFileAsync, generateRandomString } from './utils'
+import { deleteFileAndCatch, generateRandomString } from './utils'
import { extname } from 'path'
import { isArray } from './custom-validators/misc'
import { CONFIG } from '../initializers/config'
import { getExtFromMimetype } from './video'
+import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
function buildNSFWFilter (res?: express.Response, paramNSFW?: string) {
if (paramNSFW === 'true') return true
if (!files) return
if (isArray(files)) {
- (files as Express.Multer.File[]).forEach(f => deleteFileAsync(f.path))
+ (files as Express.Multer.File[]).forEach(f => deleteFileAndCatch(f.path))
return
}
for (const key of Object.keys(files)) {
const file = files[key]
- if (isArray(file)) file.forEach(f => deleteFileAsync(f.path))
- else deleteFileAsync(file.path)
+ if (isArray(file)) file.forEach(f => deleteFileAndCatch(f.path))
+ else deleteFileAndCatch(file.path)
}
}
}
function badRequest (req: express.Request, res: express.Response) {
- return res.type('json').status(400).end()
+ return res.type('json')
+ .status(HttpStatusCode.BAD_REQUEST_400)
+ .end()
}
function createReqFiles (