ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix silent 500 after resumable upload
Chocobozzz790c2837ddcb
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.tsindex 7e87df8b13..55cb9cf201 100644--- a/server/controllers/api/videos/upload.ts+++ b/server/controllers/api/videos/upload.ts@@ -2,7 +2,7 @@ import express from 'express'import { move } from 'fs-extra'import { basename } from 'path'import { getLowercaseExtension } from '@server/helpers/core-utils'-import { deleteResumableUploadMetaFile, getResumableUploadPath } from '@server/helpers/upload'+import { getResumableUploadPath } from '@server/helpers/upload'import { uuidToShort } from '@server/helpers/uuid'import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'@@ -130,9 +130,6 @@ export async function addVideoResumable (_req: express.Request, res: express.Resconst videoInfo = videoPhysicalFile.metadataconst files = { previewfile: videoInfo.previewfile }- // Don't need the meta file anymore- await deleteResumableUploadMetaFile(videoPhysicalFile.path)-return addVideo({ res, videoPhysicalFile, videoInfo, files })}diff --git a/server/helpers/upload.ts b/server/helpers/upload.tsindex 030a6b7d54..3cb17edd0a 100644--- a/server/helpers/upload.ts+++ b/server/helpers/upload.ts@@ -1,5 +1,3 @@-import { METAFILE_EXTNAME } from '@uploadx/core'-import { remove } from 'fs-extra'import { join } from 'path'import { RESUMABLE_UPLOAD_DIRECTORY } from '../initializers/constants'@@ -9,13 +7,8 @@ function getResumableUploadPath (filename?: string) {return RESUMABLE_UPLOAD_DIRECTORY}-function deleteResumableUploadMetaFile (filepath: string) {- return remove(filepath + METAFILE_EXTNAME)-}-// ---------------------------------------------------------------------------export {- getResumableUploadPath,- deleteResumableUploadMetaFile+ getResumableUploadPath}diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.tsindex 857859fd3a..59970aa943 100644--- a/server/tests/api/videos/resumable-upload.ts+++ b/server/tests/api/videos/resumable-upload.ts@@ -113,6 +113,7 @@ describe('Test resumable upload', function () {it('Should correctly delete files after an upload', async function () {const uploadId = await prepareUpload()await sendChunks({ pathUploadId: uploadId })+ await server.videos.endResumableUpload({ pathUploadId: uploadId })expect(await countResumableUploads()).to.equal(0)})diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.tsindex 5bbf7f3bf5..501e0b374b 100644--- a/shared/extra-utils/requests/requests.ts+++ b/shared/extra-utils/requests/requests.ts@@ -57,9 +57,15 @@ function makeActivityPubGetRequest (url: string, path: string, expectedStatus =})}-function makeDeleteRequest (options: CommonRequestParams) {+function makeDeleteRequest (options: CommonRequestParams & {+ query?: any+ rawQuery?: string+}) {const req = request(options.url).delete(options.path)+ if (options.query) req.query(options.query)+ if (options.rawQuery) req.query(options.rawQuery)+return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options })}diff --git a/shared/extra-utils/shared/abstract-command.ts b/shared/extra-utils/shared/abstract-command.tsindex 021045e49a..a57c857fcf 100644--- a/shared/extra-utils/shared/abstract-command.ts+++ b/shared/extra-utils/shared/abstract-command.ts@@ -40,6 +40,11 @@ interface InternalGetCommandOptions extends InternalCommonCommandOptions {query?: { [ id: string ]: any }}+interface InternalDeleteCommandOptions extends InternalCommonCommandOptions {+ query?: { [ id: string ]: any }+ rawQuery?: string+}+abstract class AbstractCommand {constructor (@@ -82,8 +87,15 @@ abstract class AbstractCommand {})}- protected deleteRequest (options: InternalCommonCommandOptions) {- return makeDeleteRequest(this.buildCommonRequestOptions(options))+ protected deleteRequest (options: InternalDeleteCommandOptions) {+ const { query, rawQuery } = options++ return makeDeleteRequest({+ ...this.buildCommonRequestOptions(options),++ query,+ rawQuery+ })}protected putBodyRequest (options: InternalCommonCommandOptions & {diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.tsindex d35339c8d4..63980c147d 100644--- a/shared/extra-utils/videos/videos-command.ts+++ b/shared/extra-utils/videos/videos-command.ts@@ -449,6 +449,8 @@ export class VideosCommand extends AbstractCommand {const result = await this.sendResumableChunks({ ...options, pathUploadId, videoFilePath, size })+ await this.endResumableUpload({ ...options, pathUploadId })+return result.body?.video || result.body as any}@@ -542,6 +544,19 @@ export class VideosCommand extends AbstractCommand {})}+ endResumableUpload (options: OverrideCommandOptions & {+ pathUploadId: string+ }) {+ return this.deleteRequest({+ ...options,++ path: '/api/v1/videos/upload-resumable',+ rawQuery: options.pathUploadId,+ implicitToken: true,+ defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204+ })+ }+quickUpload (options: OverrideCommandOptions & {name: stringnsfw?: boolean