diff options
author | q_h <q_h@inbox.ru> | 2023-06-29 11:38:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-29 10:38:37 +0200 |
commit | 926c3f2b377196af1e8c5725aa54b8077cb79061 (patch) | |
tree | 98a4a6244efb0b003e0d637e4ecd8c1fea8f598d /server/middlewares/validators/videos | |
parent | 9fe86c2c9bd9e526c80b1efa237be01617e8584a (diff) | |
download | PeerTube-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.ts | 4 |
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' | |||
2 | import { body, header, param, query, ValidationChain } from 'express-validator' | 2 | import { body, header, param, query, ValidationChain } from 'express-validator' |
3 | import { isTestInstance } from '@server/helpers/core-utils' | 3 | import { isTestInstance } from '@server/helpers/core-utils' |
4 | import { getResumableUploadPath } from '@server/helpers/upload' | 4 | import { getResumableUploadPath } from '@server/helpers/upload' |
5 | import { uploadx } from '@server/lib/uploadx' | ||
5 | import { Redis } from '@server/lib/redis' | 6 | import { Redis } from '@server/lib/redis' |
6 | import { getServerActor } from '@server/models/application/application' | 7 | import { getServerActor } from '@server/models/application/application' |
7 | import { ExpressPromiseHandler } from '@server/types/express-handler' | 8 | import { ExpressPromiseHandler } from '@server/types/express-handler' |
@@ -40,7 +41,6 @@ import { | |||
40 | } from '../../../helpers/custom-validators/videos' | 41 | } from '../../../helpers/custom-validators/videos' |
41 | import { cleanUpReqFiles } from '../../../helpers/express-utils' | 42 | import { cleanUpReqFiles } from '../../../helpers/express-utils' |
42 | import { logger } from '../../../helpers/logger' | 43 | import { logger } from '../../../helpers/logger' |
43 | import { deleteFileAndCatch } from '../../../helpers/utils' | ||
44 | import { getVideoWithAttributes } from '../../../helpers/video' | 44 | import { getVideoWithAttributes } from '../../../helpers/video' |
45 | import { CONFIG } from '../../../initializers/config' | 45 | import { CONFIG } from '../../../initializers/config' |
46 | import { CONSTRAINTS_FIELDS, OVERVIEWS } from '../../../initializers/constants' | 46 | import { 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) |