aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos
diff options
context:
space:
mode:
authorq_h <q_h@inbox.ru>2023-06-29 11:38:37 +0300
committerGitHub <noreply@github.com>2023-06-29 10:38:37 +0200
commit926c3f2b377196af1e8c5725aa54b8077cb79061 (patch)
tree98a4a6244efb0b003e0d637e4ecd8c1fea8f598d /server/middlewares/validators/videos
parent9fe86c2c9bd9e526c80b1efa237be01617e8584a (diff)
downloadPeerTube-926c3f2b377196af1e8c5725aa54b8077cb79061.tar.gz
PeerTube-926c3f2b377196af1e8c5725aa54b8077cb79061.tar.zst
PeerTube-926c3f2b377196af1e8c5725aa54b8077cb79061.zip
Fix the cleanup after a failed upload (#5840)
* Fix the cleanup after a failed upload * Update tests * Update tests
Diffstat (limited to 'server/middlewares/validators/videos')
-rw-r--r--server/middlewares/validators/videos/videos.ts4
1 files changed, 2 insertions, 2 deletions
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'
2import { body, header, param, query, ValidationChain } from 'express-validator' 2import { body, header, param, query, ValidationChain } from 'express-validator'
3import { isTestInstance } from '@server/helpers/core-utils' 3import { isTestInstance } from '@server/helpers/core-utils'
4import { getResumableUploadPath } from '@server/helpers/upload' 4import { getResumableUploadPath } from '@server/helpers/upload'
5import { uploadx } from '@server/lib/uploadx'
5import { Redis } from '@server/lib/redis' 6import { Redis } from '@server/lib/redis'
6import { getServerActor } from '@server/models/application/application' 7import { getServerActor } from '@server/models/application/application'
7import { ExpressPromiseHandler } from '@server/types/express-handler' 8import { ExpressPromiseHandler } from '@server/types/express-handler'
@@ -40,7 +41,6 @@ import {
40} from '../../../helpers/custom-validators/videos' 41} from '../../../helpers/custom-validators/videos'
41import { cleanUpReqFiles } from '../../../helpers/express-utils' 42import { cleanUpReqFiles } from '../../../helpers/express-utils'
42import { logger } from '../../../helpers/logger' 43import { logger } from '../../../helpers/logger'
43import { deleteFileAndCatch } from '../../../helpers/utils'
44import { getVideoWithAttributes } from '../../../helpers/video' 44import { getVideoWithAttributes } from '../../../helpers/video'
45import { CONFIG } from '../../../initializers/config' 45import { CONFIG } from '../../../initializers/config'
46import { CONSTRAINTS_FIELDS, OVERVIEWS } from '../../../initializers/constants' 46import { CONSTRAINTS_FIELDS, OVERVIEWS } from '../../../initializers/constants'
@@ -115,7 +115,7 @@ const videosAddResumableValidator = [
115 const user = res.locals.oauth.token.User 115 const user = res.locals.oauth.token.User
116 const body: express.CustomUploadXFile<express.UploadXFileMetadata> = req.body 116 const body: express.CustomUploadXFile<express.UploadXFileMetadata> = req.body
117 const file = { ...body, duration: undefined, path: getResumableUploadPath(body.name), filename: body.metadata.filename } 117 const file = { ...body, duration: undefined, path: getResumableUploadPath(body.name), filename: body.metadata.filename }
118 const cleanup = () => deleteFileAndCatch(file.path) 118 const cleanup = () => uploadx.storage.delete(file).catch(err => logger.error('Cannot delete the file %s', file.name, { err }))
119 119
120 const uploadId = req.query.upload_id 120 const uploadId = req.query.upload_id
121 const sessionExists = await Redis.Instance.doesUploadSessionExist(uploadId) 121 const sessionExists = await Redis.Instance.doesUploadSessionExist(uploadId)