From 926c3f2b377196af1e8c5725aa54b8077cb79061 Mon Sep 17 00:00:00 2001 From: q_h Date: Thu, 29 Jun 2023 11:38:37 +0300 Subject: Fix the cleanup after a failed upload (#5840) * Fix the cleanup after a failed upload * Update tests * Update tests --- server/middlewares/validators/videos/videos.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/middlewares/validators/videos') diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 9034772c0..b829e4eb4 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts @@ -2,6 +2,7 @@ import express from 'express' import { body, header, param, query, ValidationChain } from 'express-validator' import { isTestInstance } from '@server/helpers/core-utils' import { getResumableUploadPath } from '@server/helpers/upload' +import { uploadx } from '@server/lib/uploadx' import { Redis } from '@server/lib/redis' import { getServerActor } from '@server/models/application/application' import { ExpressPromiseHandler } from '@server/types/express-handler' @@ -40,7 +41,6 @@ import { } from '../../../helpers/custom-validators/videos' import { cleanUpReqFiles } from '../../../helpers/express-utils' import { logger } from '../../../helpers/logger' -import { deleteFileAndCatch } from '../../../helpers/utils' import { getVideoWithAttributes } from '../../../helpers/video' import { CONFIG } from '../../../initializers/config' import { CONSTRAINTS_FIELDS, OVERVIEWS } from '../../../initializers/constants' @@ -115,7 +115,7 @@ const videosAddResumableValidator = [ const user = res.locals.oauth.token.User const body: express.CustomUploadXFile = req.body const file = { ...body, duration: undefined, path: getResumableUploadPath(body.name), filename: body.metadata.filename } - const cleanup = () => deleteFileAndCatch(file.path) + const cleanup = () => uploadx.storage.delete(file).catch(err => logger.error('Cannot delete the file %s', file.name, { err })) const uploadId = req.query.upload_id const sessionExists = await Redis.Instance.doesUploadSessionExist(uploadId) -- cgit v1.2.3