From fca58de835b929121fdf0b91a29cac9d9e0e4019 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 11 Oct 2023 15:13:54 +0200 Subject: [PATCH 1/4] Fix runner test --- packages/tests/src/shared/peertube-runner-process.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/tests/src/shared/peertube-runner-process.ts b/packages/tests/src/shared/peertube-runner-process.ts index 784d81235..414d1f5bf 100644 --- a/packages/tests/src/shared/peertube-runner-process.ts +++ b/packages/tests/src/shared/peertube-runner-process.ts @@ -1,5 +1,5 @@ import { ChildProcess, fork, ForkOptions } from 'child_process' -import { execa } from 'execa' +import { execaNode } from 'execa' import { join } from 'path' import { root } from '@peertube/peertube-node-utils' import { PeerTubeServer } from '@peertube/peertube-server-commands' @@ -99,6 +99,6 @@ export class PeerTubeRunnerProcess { } private runCommand (path: string, args: string[]) { - return execa.node(path, args, { env: { ...process.env, NODE_OPTIONS: '' } }) + return execaNode(path, args, { env: { ...process.env, NODE_OPTIONS: '' } }) } } From 71ba1ead4ffa0d026b6d650ed821366abddb9a6f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 11 Oct 2023 15:29:11 +0200 Subject: [PATCH 2/4] Fix types test --- scripts/ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci.sh b/scripts/ci.sh index 0046fe41a..d06f1c675 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -51,7 +51,7 @@ if [ "$1" = "types-package" ]; then cp -r packages/types-generator/dist /tmp/types-generator/dist (cd /tmp/types-generator/dist && npm install) - npm run tsc -- --noEmit --esModuleInterop --moduleResolution node16 /tmp/types-generator/tests/test.ts + npm run tsc -- --noEmit --esModuleInterop --moduleResolution node16 --module Node16 /tmp/types-generator/tests/test.ts rm -r /tmp/types-generator elif [ "$1" = "client" ]; then npm run build From 72433932724364c5c2301e73ff06b6f37467884c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 11 Oct 2023 15:58:16 +0200 Subject: [PATCH 3/4] Fix signup and import --- server/core/controllers/api/videos/import.ts | 3 ++- server/core/lib/signup.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/core/controllers/api/videos/import.ts b/server/core/controllers/api/videos/import.ts index 185215cc9..5e6694899 100644 --- a/server/core/controllers/api/videos/import.ts +++ b/server/core/controllers/api/videos/import.ts @@ -237,7 +237,8 @@ async function processTorrentOrAbortRequest (req: express.Request, res: express. torrentfile.path = newTorrentPath const buf = await readFile(torrentfile.path) - const parsedTorrent = parseTorrent(buf) as Instance + // FIXME: typings: parseTorrent now returns an async result + const parsedTorrent = await (parseTorrent(buf) as unknown as Promise) if (parsedTorrent.files.length !== 1) { cleanUpReqFiles(req) diff --git a/server/core/lib/signup.ts b/server/core/lib/signup.ts index a5e9e93c9..f4e0aef65 100644 --- a/server/core/lib/signup.ts +++ b/server/core/lib/signup.ts @@ -38,7 +38,7 @@ export function isSignupAllowedForCurrentIP (ip: string) { let matched = '' // if there is a valid, non-empty whitelist, we exclude all unknown addresses too - if (CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.filter(cidr => isIPV4Cidr(cidr) || isIPV6Cidr(cidr))) { + if (CONFIG.SIGNUP.FILTERS.CIDR.WHITELIST.some(cidr => isIPV4Cidr(cidr) || isIPV6Cidr(cidr))) { excludeList.push('unknown') } From 5bd42bbca7f44a92e6a813c74c99329acead81f3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 11 Oct 2023 16:17:11 +0200 Subject: [PATCH 4/4] Fix resumable tests --- .../tests/src/api/videos/resumable-upload.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/tests/src/api/videos/resumable-upload.ts b/packages/tests/src/api/videos/resumable-upload.ts index 628e0298c..1f97ab4d1 100644 --- a/packages/tests/src/api/videos/resumable-upload.ts +++ b/packages/tests/src/api/videos/resumable-upload.ts @@ -183,14 +183,9 @@ describe('Test resumable upload', function () { it('Should not accept more chunks than expected with an invalid content length/content range', async function () { const uploadId = await prepareUpload({ size: 1500 }) - // Content length check can be different depending on the node version - try { - await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentLength: 1000 }) - await checkFileSize(uploadId, 0) - } catch { - await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.BAD_REQUEST_400, contentLength: 1000 }) - await checkFileSize(uploadId, 0) - } + await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentLength: 1000 }) + + await checkFileSize(uploadId, 0) }) it('Should not accept more chunks than expected with an invalid content length', async function () { @@ -198,13 +193,8 @@ describe('Test resumable upload', function () { const size = 1000 - // Content length check seems to have changed in v16 - const expectedStatus = process.version.startsWith('v16') - ? HttpStatusCode.CONFLICT_409 - : HttpStatusCode.BAD_REQUEST_400 - const contentRangeBuilder = (start: number) => `bytes ${start}-${start + size - 1}/${size}` - await sendChunks({ pathUploadId: uploadId, expectedStatus, contentRangeBuilder, contentLength: size }) + await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentRangeBuilder, contentLength: size }) await checkFileSize(uploadId, 0) })