Merge retry hardening with DSP cache opt-in

This commit is contained in:
Jonathan Sykes
2026-10-10 23:00:32 +08:00
10 changed files with 282 additions and 26 deletions

View File

@@ -162,7 +162,7 @@
const completionKey = manifest => '/__ytp_completion/' + manifest.buildTag;
async function complete(manifest, { cache, fetchFn, cycles = 4, now = Date.now, optIns,
sleep = ms => new Promise(resolve => setTimeout(resolve, ms)), baseDelay = 1000,
maxDelay = 30000, notify = () => {}, force = false } = {}) {
maxDelay = 30000, notify = () => {}, force = false, concurrency = 1 } = {}) {
const key = completionKey(manifest), saved = await cache.match(key);
let job = saved ? await saved.json() : { failures: 0, nextRetryAt: 0 };
const selectedOptIns = optIns || await readOptIns(cache);
@@ -177,7 +177,7 @@
for (let cycle = 0; cycle < cycles; cycle++) {
await publish(true);
let error;
try { await syncAssets(manifest, { cache, fetchFn, all: true, optIns: selectedOptIns }); }
try { await syncAssets(manifest, { cache, fetchFn, all: true, optIns: selectedOptIns, concurrency }); }
catch (failure) { error = failure; }
snapshot = await completeness(manifest, cache, { optIns: selectedOptIns });
if (snapshot.offlineReady) { job.failures = 0; job.nextRetryAt = 0; job.error = null; await publish(false); return job; }