This commit is contained in:
2023-05-30 16:35:23 +08:00
parent 0e093297bc
commit 7cfb63ecbf
3 changed files with 6 additions and 11 deletions

View File

@@ -9,11 +9,6 @@ export const handler: Handlers = {
return new Response("Bad Request", { status: 400 });
}
const m = get_task_manager();
try {
return get_export_zip_response(gid, m.db);
} catch (e) {
console.error(e);
return new Response("Gallery not found.", { status: 404 });
}
return get_export_zip_response(gid, m.db);
},
};

View File

@@ -4,7 +4,7 @@ import { addZero } from "../utils.ts";
export function get_export_zip_response(gid: number, db: EhDb) {
const gmeta = db.get_gmeta_by_gid(gid);
if (!gmeta) throw Error("Gallery not found.");
if (!gmeta) return new Response("Gallery not found.", { status: 404 });
const pmetas = db.get_pmeta(gid).sort((a, b) => a.index - b.index);
const p = pmetas.length;
const l = gmeta.filecount.toString().length;

View File

@@ -48,10 +48,10 @@ export class TaskManager extends EventTarget {
// @ts-ignore Checked type
addEventListener<T extends keyof EventMap>(
type: T,
callback: ((e: EventMap[T]) => void | Promise<void>) | null,
callback: (e: EventMap[T]) => void | Promise<void>,
options?: boolean | AddEventListenerOptions,
): void {
super.addEventListener(type, <EventListener | null> callback, options);
super.addEventListener(type, <EventListener> callback, options);
}
get aborted() {
return this.#abort.signal.aborted;
@@ -147,12 +147,12 @@ export class TaskManager extends EventTarget {
// @ts-ignore Checked type
removeEventListener<T extends keyof EventMap>(
type: T,
callback: ((e: EventMap[T]) => void | Promise<void>) | null,
callback: (e: EventMap[T]) => void | Promise<void>,
options?: boolean | EventListenerOptions,
): void {
super.removeEventListener(
type,
<EventListener | null> callback,
<EventListener> callback,
options,
);
}