fix: make the progress export actually reach the disk
Export is the whole of this app's backup story. Progress, streaks, ignores and every game and event the reader typed in live in one browser and nowhere else — no account, no server, nothing to restore from — so the download either happens or the data was never backed up. Two things made it a coin toss. The anchor was never in the document, which is not reliably clickable, and the object URL was revoked in the same task as the click, which can pull the blob away before the download has read it. Both fail silently and look exactly like a successful export. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
1e7a7abc64
commit
14f6f2f0dc
+10
-1
@@ -866,8 +866,17 @@ function exportProgress(
|
|||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = `event-clock-progress-${new Date().toISOString().slice(0, 10)}.json`;
|
a.download = `event-clock-progress-${new Date().toISOString().slice(0, 10)}.json`;
|
||||||
|
// In the document, and revoked on a later task. This is the only copy of
|
||||||
|
// everything the reader typed, ticked and marked — there is no account and no
|
||||||
|
// server that has ever seen it — so a download that quietly does not happen is
|
||||||
|
// the lossy backup this function exists to prevent. A detached anchor is not
|
||||||
|
// reliably clickable, and revoking the URL in the same task can pull the blob
|
||||||
|
// out from under a download that had not started reading it yet.
|
||||||
|
a.style.display = "none";
|
||||||
|
document.body.append(a);
|
||||||
a.click();
|
a.click();
|
||||||
URL.revokeObjectURL(url);
|
a.remove();
|
||||||
|
setTimeout(() => URL.revokeObjectURL(url), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function importProgress(
|
async function importProgress(
|
||||||
|
|||||||
Reference in New Issue
Block a user