diff --git a/server/export_zip.ts b/server/export_zip.ts index 0e34827..7925bf2 100644 --- a/server/export_zip.ts +++ b/server/export_zip.ts @@ -1,6 +1,6 @@ import { Uint8ArrayReader, ZipWriter } from "zipjs/index.js"; import { EhDb, PMeta } from "../db.ts"; -import { addZero } from "../utils.ts"; +import { addZero, configureZipJs } from "../utils.ts"; export function get_export_zip_response(gid: number, db: EhDb) { const gmeta = db.get_gmeta_by_gid(gid); @@ -36,6 +36,7 @@ export function get_export_zip_response(gid: number, db: EhDb) { bn += s; }, }); + configureZipJs(); const zip_writer = new ZipWriter(s); let zip_closed = false; let closed = false; diff --git a/tasks/export_zip.ts b/tasks/export_zip.ts index 4424d46..71c5668 100644 --- a/tasks/export_zip.ts +++ b/tasks/export_zip.ts @@ -1,7 +1,12 @@ import { join } from "std/path/mod.ts"; import { Uint8ArrayReader, ZipWriter } from "zipjs/index.js"; import { EhDb } from "../db.ts"; -import { addZero, asyncForEach, filterFilename } from "../utils.ts"; +import { + addZero, + asyncForEach, + configureZipJs, + filterFilename, +} from "../utils.ts"; import { Config } from "../config.ts"; import { Task, TaskExportZipProgress, TaskType } from "../task.ts"; import { TaskManager } from "../task_manager.ts"; @@ -44,6 +49,7 @@ export async function export_zip( truncate: true, }); try { + configureZipJs(); const z = new ZipWriter(f.writable, { signal, level: 0, diff --git a/utils.ts b/utils.ts index a5033f7..a47daf9 100644 --- a/utils.ts +++ b/utils.ts @@ -1,6 +1,7 @@ import { exists, existsSync } from "std/fs/exists.ts"; import { extname } from "std/path/mod.ts"; import { initParser } from "deno_dom/deno-dom-wasm-noinit.ts"; +import { configure } from "zipjs/index.js"; export function sleep(time: number): Promise { return new Promise((r) => { @@ -143,3 +144,11 @@ export type DiscriminatedUnion< ? { [Q in keyof U]: U[Q] } : never; }[keyof T]; + +let zipjs_configured = false; + +export function configureZipJs() { + if (zipjs_configured) return; + configure({useWebWorkers: false}); + zipjs_configured = true; +}