aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/resumable-upload.ts
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/tests/api/videos/resumable-upload.ts
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/tests/api/videos/resumable-upload.ts')
-rw-r--r--server/tests/api/videos/resumable-upload.ts24
1 files changed, 15 insertions, 9 deletions
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index 9de622281..91eb61833 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -93,10 +93,10 @@ describe('Test resumable upload', function () {
93 expect((await stat(filePath)).size).to.equal(expectedSize) 93 expect((await stat(filePath)).size).to.equal(expectedSize)
94 } 94 }
95 95
96 async function countResumableUploads () { 96 async function countResumableUploads (wait?: number) {
97 const subPath = join('tmp', 'resumable-uploads') 97 const subPath = join('tmp', 'resumable-uploads')
98 const filePath = server.servers.buildDirectory(subPath) 98 const filePath = server.servers.buildDirectory(subPath)
99 99 await new Promise(resolve => setTimeout(resolve, wait))
100 const files = await readdir(filePath) 100 const files = await readdir(filePath)
101 return files.length 101 return files.length
102 } 102 }
@@ -122,14 +122,20 @@ describe('Test resumable upload', function () {
122 122
123 describe('Directory cleaning', function () { 123 describe('Directory cleaning', function () {
124 124
125 // FIXME: https://github.com/kukhariev/node-uploadx/pull/524/files#r852989382 125 it('Should correctly delete files after an upload', async function () {
126 // it('Should correctly delete files after an upload', async function () { 126 const uploadId = await prepareUpload()
127 // const uploadId = await prepareUpload() 127 await sendChunks({ pathUploadId: uploadId })
128 // await sendChunks({ pathUploadId: uploadId }) 128 await server.videos.endResumableUpload({ pathUploadId: uploadId })
129 // await server.videos.endResumableUpload({ pathUploadId: uploadId }) 129
130 expect(await countResumableUploads()).to.equal(0)
131 })
130 132
131 // expect(await countResumableUploads()).to.equal(0) 133 it('Should correctly delete corrupt files', async function () {
132 // }) 134 const uploadId = await prepareUpload({ size: 8 * 1024 })
135 await sendChunks({ pathUploadId: uploadId, size: 8 * 1024, expectedStatus: HttpStatusCode.UNPROCESSABLE_ENTITY_422 })
136
137 expect(await countResumableUploads(2000)).to.equal(0)
138 })
133 139
134 it('Should not delete files after an unfinished upload', async function () { 140 it('Should not delete files after an unfinished upload', async function () {
135 await prepareUpload() 141 await prepareUpload()