aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/middlewares/validators/videos/videos.ts12
-rw-r--r--server/tests/api/videos/resumable-upload.ts18
2 files changed, 26 insertions, 4 deletions
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 7f1f39b11..fc2f95aa5 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -132,11 +132,15 @@ const videosAddResumableValidator = [
132 }) 132 })
133 } 133 }
134 134
135 if (isTestInstance()) { 135 const videoStillExists = await VideoModel.load(sessionResponse.video.id)
136 res.setHeader('x-resumable-upload-cached', 'true') 136
137 } 137 if (videoStillExists) {
138 if (isTestInstance()) {
139 res.setHeader('x-resumable-upload-cached', 'true')
140 }
138 141
139 return res.json(sessionResponse) 142 return res.json(sessionResponse)
143 }
140 } 144 }
141 145
142 await Redis.Instance.setUploadSession(uploadId) 146 await Redis.Instance.setUploadSession(uploadId)
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index 2fbefb392..9de622281 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -254,6 +254,24 @@ describe('Test resumable upload', function () {
254 expect(result2.headers['x-resumable-upload-cached']).to.not.exist 254 expect(result2.headers['x-resumable-upload-cached']).to.not.exist
255 }) 255 })
256 256
257 it('Should not cache after video deletion', async function () {
258 const originalName = 'toto.mp4'
259 const lastModified = new Date().getTime()
260
261 const uploadId1 = await prepareUpload({ originalName, lastModified })
262 const result1 = await sendChunks({ pathUploadId: uploadId1 })
263 await server.videos.remove({ id: result1.body.video.uuid })
264
265 const uploadId2 = await prepareUpload({ originalName, lastModified })
266 const result2 = await sendChunks({ pathUploadId: uploadId2 })
267 expect(result1.body.video.uuid).to.not.equal(result2.body.video.uuid)
268
269 expect(result2.headers['x-resumable-upload-cached']).to.not.exist
270
271 await checkFileSize(uploadId1, null)
272 await checkFileSize(uploadId2, null)
273 })
274
257 it('Should refuse an invalid digest', async function () { 275 it('Should refuse an invalid digest', async function () {
258 const uploadId = await prepareUpload({ token: server.accessToken }) 276 const uploadId = await prepareUpload({ token: server.accessToken })
259 277