From 37aa05b1e11e3ded6e751be8b768ae5927ec6a67 Mon Sep 17 00:00:00 2001 From: admin <362324317@qq.com> Date: Fri, 15 May 2026 06:48:23 +0800 Subject: [PATCH] =?UTF-8?q?revert:=20=E5=8E=BB=E6=8E=89=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91,=20?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E7=BA=AFIP+is=5Fprimary=E5=88=86=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 网盘分享按新资源奖励机制, 不需追资源转存历史 - getAndValidateCredential 去掉 shareUrl 参数 - 保留 save_records.config_id 字段(仅用于日志排查) --- packages/backend/src/cloud/cloud.service.ts | 2 +- .../backend/src/cloud/credential.service.ts | 27 +------------------ 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/packages/backend/src/cloud/cloud.service.ts b/packages/backend/src/cloud/cloud.service.ts index 70e488d..f5c6c3d 100644 --- a/packages/backend/src/cloud/cloud.service.ts +++ b/packages/backend/src/cloud/cloud.service.ts @@ -141,7 +141,7 @@ async function doSaveFromShare(shareUrl: string, cloudType: string, sourceTitle? } // ── Unified credential validation ── - const credential = await getAndValidateCredential(cloudType, ipAddress, shareUrl); + const credential = await getAndValidateCredential(cloudType, ipAddress); if (!credential.valid || !credential.config) { return { success: false, message: credential.message }; } diff --git a/packages/backend/src/cloud/credential.service.ts b/packages/backend/src/cloud/credential.service.ts index bdfa923..f079de9 100644 --- a/packages/backend/src/cloud/credential.service.ts +++ b/packages/backend/src/cloud/credential.service.ts @@ -423,37 +423,12 @@ export interface CredentialValidationResult { * * Reference: search-ucmao get_and_validate_credential() pattern. */ -export async function getAndValidateCredential(cloudType: string, ipAddress?: string, shareUrl?: string): Promise { +export async function getAndValidateCredential(cloudType: string, ipAddress?: string): Promise { const db = getDb(); let config: CloudConfig | undefined; - // ── Resource history lookup: if this share URL was saved before, reuse that account ── - if (shareUrl) { - const historyRecord = db.prepare( - `SELECT config_id, target_cloud, folder_name FROM save_records - WHERE share_url = ? AND target_cloud = ? AND status IN ('success', 'reused') - ORDER BY id DESC LIMIT 1` - ).get(shareUrl, cloudType) as { config_id: number; target_cloud: string; folder_name: string } | undefined; - if (historyRecord) { - // Resource was previously saved — reuse the exact same config if still healthy - if (historyRecord.config_id) { - config = db.prepare( - `SELECT * FROM cloud_configs WHERE id = ? AND is_active = 1 AND consecutive_failures < 5` - ).get(historyRecord.config_id) as CloudConfig | undefined; - } - if (!config) { - // Fallback: pick any healthy account from this cloud type - config = db.prepare( - `SELECT * FROM cloud_configs - WHERE cloud_type = ? AND is_active = 1 AND consecutive_failures < 5 - ORDER BY is_primary DESC, last_used_at ASC NULLS FIRST - LIMIT 1` - ).get(cloudType) as CloudConfig | undefined; - } - } - } if (!ipAddress) { // No IP info — fallback to simple LUR