v0.3.50: Retry save creates new folder with random suffix to produce genuinely different share link

This commit is contained in:
2026-05-18 01:24:37 +08:00
parent 7f4ab50557
commit 9f959ca87b
10 changed files with 15 additions and 1588 deletions

View File

@@ -48,6 +48,9 @@ async function doSaveFromShare(shareUrl: string, cloudType: string, sourceTitle?
const db = getDb();
const ipLocation = await lookupIpLocation(ipAddress || '');
// ── Track if this is a re-save after link was found invalid
let retrySave = false;
// ── Short-term dedup: prevent duplicate saves of the same URL within 60 seconds ──
const DEDUP_WINDOW_SEC = 60;
let dedupCutoff = '';
@@ -78,6 +81,7 @@ async function doSaveFromShare(shareUrl: string, cloudType: string, sourceTitle?
if (dedupValidation.status !== 'valid') {
dedupLinkInvalid = true;
console.log(`[Share] 🛡️ Dedup link invalid (${dedupValidation.message}), falling through to normal save`);
retrySave = true;
}
} catch (err: any) {
console.log(`[Share] 🛡️ Dedup validation error: ${err.message}, falling through`);
@@ -150,6 +154,7 @@ async function doSaveFromShare(shareUrl: string, cloudType: string, sourceTitle?
file_count: 0, folder_count: 0, duration_ms: 0,
};
}
retrySave = true;
console.log(`[Share] Existing share link for ${shareUrl} is invalid/expired, will re-save`);
}
} catch (err: any) {
@@ -171,7 +176,7 @@ async function doSaveFromShare(shareUrl: string, cloudType: string, sourceTitle?
switch (cloudType) {
case 'quark': {
const driver = new QuarkDriver({ cookie: config.cookie!, nickname: config.nickname });
driverResult = await driver.saveFromShare(shareUrl, sourceTitle);
driverResult = await driver.saveFromShare(shareUrl, sourceTitle, retrySave);
break;
}
case 'baidu': {