From 941b082a7202a22936b6e56b42c089231c68ddf1 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Sat, 25 Apr 2026 13:23:35 +0800 Subject: [PATCH] feat(export): enhance export functionality with new download method and configuration updates - Introduced a new function to open export downloads in a new tab, improving user experience for task downloads. - Updated the export job service to use more precise checks for task expiration, enhancing reliability. - Modified the .gitignore to include temporary files, ensuring a cleaner project structure. These changes streamline the export process and improve the management of temporary files. --- .gitignore | 3 ++- app/pages/me/export/index.vue | 8 +++++--- packages/drizzle-pkg/db.sqlite | Bin 163840 -> 163840 bytes server/service/export/jobs.ts | 13 ++++++++----- 4 files changed, 15 insertions(+), 9 deletions(-) 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 3d57799dc6e6e3eb8bfa10805a6796e50769ec1e..8f67caef53375053354ad5de7cf82b22fd44decd 100644 GIT binary patch delta 312 zcmZo@;A&{#njp>id7_LncOpc5{w+kdN-Qs6uVdi9Hnf^YXNrCb7c7Xz>z5G1#jBp>b KOut#rqz(YaQD(US delta 350 zcmZo@;A&{#njp=1d!mdprP`bvgMMn5BhbT%eJg zic0hHGV{`l63c<+H41Wo6iBif8!~D}vx4kwWMt-N;FMR8WNlwq%+P1idlfkMkXeZ0YLq%IQ4VhYM)*h$E3=bIDKIZ zlj!u-@l5<8V6zO&jsi{Lyj2S(k4`@q&*aGXal1eQ(=C2hW@bj-N7LWuGbu3kY!@hC U+RM+w%`D9b4F=BXH|v?y0b%-Sf&c&j 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";