From 9243994c5953fd4409d02bf9514a9f6af56bec2a Mon Sep 17 00:00:00 2001 From: WakelessSloth56 Date: Sat, 11 Jan 2025 11:59:59 +0800 Subject: [PATCH] feat: wasm plugin throws error if file size over 4GB #5097 --- registry/lib/plugins/video/download/wasm-output/handler.ts | 6 +++++- registry/lib/plugins/video/download/wasm-output/index.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/registry/lib/plugins/video/download/wasm-output/handler.ts b/registry/lib/plugins/video/download/wasm-output/handler.ts index 4be359a0dd..1f39bad3ff 100644 --- a/registry/lib/plugins/video/download/wasm-output/handler.ts +++ b/registry/lib/plugins/video/download/wasm-output/handler.ts @@ -2,7 +2,7 @@ import { DownloadPackage, PackageEntry } from '@/core/download' import { meta } from '@/core/meta' import { getComponentSettings } from '@/core/settings' import { Toast } from '@/core/toast' -import { formatPercent } from '@/core/utils/formatters' +import { formatFileSize, formatPercent } from '@/core/utils/formatters' import { title as pluginTitle } from '.' import type { Options } from '../../../../components/video/download' import { DownloadVideoAction } from '../../../../components/video/download/types' @@ -139,6 +139,10 @@ export async function run(action: DownloadVideoAction, muxWithMetadata: boolean) throw new Error('仅支持 DASH 格式视频和音频') } + if (video.size + audio.size > 4294967295) { + throw new Error(`仅支持合并 4GB 内的音视频(${formatFileSize(video.size + audio.size)})`) + } + await single( video.title, video.url, diff --git a/registry/lib/plugins/video/download/wasm-output/index.ts b/registry/lib/plugins/video/download/wasm-output/index.ts index d5039f2592..97ae9d1513 100644 --- a/registry/lib/plugins/video/download/wasm-output/index.ts +++ b/registry/lib/plugins/video/download/wasm-output/index.ts @@ -19,7 +19,7 @@ export const plugin: PluginMetadata = { outputs.push({ name: 'wasm', displayName: 'WASM', - description: `${desc}。运行过程中请勿关闭页面,初次使用或清除缓存后需要加载约 30 MB 的 WASM 文件。`, + description: `${desc}。运行过程中请勿关闭页面,初次使用或清除缓存后需要加载约 30 MB 的 WASM 文件。由于浏览器限制,仅支持合并 4GB 以内的音视频。`, runAction: async (action, instance) => { try { await run(action, instance.muxWithMetadata)