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