diff --git a/.gitignore b/.gitignore index 27572c7..16483ee 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ logs # Local git worktrees .worktrees -static/* \ No newline at end of file +static/* +.tmp/* \ No newline at end of file diff --git a/app/pages/me/export/index.vue b/app/pages/me/export/index.vue index 42e312c..56dc751 100644 --- a/app/pages/me/export/index.vue +++ b/app/pages/me/export/index.vue @@ -58,6 +58,10 @@ function taskDownloadUrl(taskId: number): string { return `/api/me/export/tasks/${taskId}/download` } +function openExportDownload(taskId: number) { + window.open(taskDownloadUrl(taskId), '_blank', 'noopener,noreferrer') +} + async function loadTasks() { const useBlocking = tasks.value.length === 0 if (useBlocking) { @@ -215,10 +219,8 @@ onMounted(() => { 下载 diff --git a/packages/drizzle-pkg/db.sqlite b/packages/drizzle-pkg/db.sqlite index 3d57799..8f67cae 100644 Binary files a/packages/drizzle-pkg/db.sqlite and b/packages/drizzle-pkg/db.sqlite differ diff --git a/server/service/export/jobs.ts b/server/service/export/jobs.ts index c161d88..b901a30 100644 --- a/server/service/export/jobs.ts +++ b/server/service/export/jobs.ts @@ -2,7 +2,7 @@ import fs from "node:fs/promises"; import path from "node:path"; import { dbGlobal } from "drizzle-pkg/lib/db"; import { userExportTasks } from "drizzle-pkg/lib/schema/export"; -import { and, desc, eq, or, sql } from "drizzle-orm"; +import { and, desc, eq, gt, isNotNull, or, sql } from "drizzle-orm"; import { nextIntegerId } from "../../utils/sqlite-id"; import { RELATIVE_TMP_DIR } from "#server/constants/media"; @@ -24,7 +24,7 @@ function positiveBigIntFromEnv(name: string, fallback: bigint): bigint { } try { const n = BigInt(raw); - return n > 0n ? n : fallback; + return n > BigInt(0) ? n : fallback; } catch { return fallback; } @@ -32,7 +32,10 @@ function positiveBigIntFromEnv(name: string, fallback: bigint): bigint { const EXPORT_MAX_RUNNING_TASKS = positiveIntFromEnv("EXPORT_MAX_RUNNING_TASKS", 2); const EXPORT_MAX_QUEUED_TASKS = positiveIntFromEnv("EXPORT_MAX_QUEUED_TASKS", 30); -const EXPORT_MAX_RETAINED_BYTES = positiveBigIntFromEnv("EXPORT_MAX_RETAINED_BYTES", 2n * 1024n * 1024n * 1024n); +const EXPORT_MAX_RETAINED_BYTES = positiveBigIntFromEnv( + "EXPORT_MAX_RETAINED_BYTES", + BigInt(2) * BigInt(1024) * BigInt(1024) * BigInt(1024), +); function exportRootDir(): string { return path.resolve(process.cwd(), RELATIVE_TMP_DIR, "exports"); @@ -121,8 +124,8 @@ export async function createExportTask(params: { userId: number; maskPolicy: Exp .where( and( eq(userExportTasks.status, "succeeded"), - sql`${userExportTasks.expiresAt} IS NOT NULL`, - sql`${userExportTasks.expiresAt} > ${now}`, + isNotNull(userExportTasks.expiresAt), + gt(userExportTasks.expiresAt, now), ), ); const retainedBytes = retainedRows[0]?.retainedBytes ?? "0";