fix: recover old GTIN service worker caches

This commit is contained in:
desfoto automation
2026-09-25 20:08:25 +02:00
parent de6de3c6c4
commit 5e7fa9be05
11 changed files with 140 additions and 3 deletions

View File

@@ -0,0 +1,33 @@
/* Entfernt die umgeleitete Startantwort aus frueheren GTIN-Caches. */
const status = document.querySelector('#status');
const appUrl = new URL('../', window.location.href);
const alterIndex = new URL('index.html', appUrl).href;
async function aktualisiereWerkzeug() {
if ('caches' in window) {
const namen = await caches.keys();
for (const name of namen) {
if (!name.startsWith('desfoto-gtin-generator-')) continue;
const cache = await caches.open(name);
const antwort = await cache.match(alterIndex);
if (antwort?.redirected) await cache.delete(alterIndex);
}
}
if ('serviceWorker' in navigator) {
const registrierung = await navigator.serviceWorker.getRegistration(appUrl.href);
if (registrierung) {
await Promise.race([
registrierung.update().catch(() => undefined),
new Promise((resolve) => window.setTimeout(resolve, 5000)),
]);
}
}
window.location.replace(appUrl.href);
}
aktualisiereWerkzeug().catch(() => {
status.textContent = 'Die Aktualisierung ist fehlgeschlagen. Bitte lösche die Website-Daten für desfoto.de in deinem Browser und öffne das Werkzeug erneut.';
});