Skip to content

Commit

Permalink
feat: wasm plugin throws error if file size over 4GB
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Jan 11, 2025
1 parent 12b9868 commit 9243994
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion registry/lib/plugins/video/download/wasm-output/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion registry/lib/plugins/video/download/wasm-output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9243994

Please sign in to comment.