feat: add non-blocking RAID status refresh with dedicated lock and remove offline navigation fallback from service worker

Add raid_refresh_lock to prevent concurrent RAID refresh operations. Extract refresh_raid_status() function with non-blocking lock acquisition using acquire(blocking=False). Update datastore_snapshot() to spawn background thread for RAID refresh when cache is stale but return immediately with cached data. Remove offline navigation fallback from service worker to prevent masking backend errors. Bump service worker cache version to v7
This commit is contained in:
2026-08-21 21:02:27 +02:00
parent 5d7e452aaf
commit 6aa4032134
3 changed files with 34 additions and 14 deletions
+5 -4
View File
@@ -1,4 +1,4 @@
const CACHE_NAME = 'media-max-shell-v6';
const CACHE_NAME = 'media-max-shell-v7';
const SHELL = ['/static/media-mark.svg', '/static/media-mark-192.png', '/static/media-mark-512.png', '/static/manifest.json'];
self.addEventListener('install', event => {
@@ -16,10 +16,11 @@ self.addEventListener('fetch', event => {
if (request.method !== 'GET') return;
const url = new URL(request.url);
if (url.pathname.startsWith('/api/')) return;
// Navigation requests must stay real network requests. Returning an
// offline document here can mask backend errors and make the app appear
// disconnected after a scan/reload.
if (request.mode === 'navigate') return;
event.respondWith(fetch(request).catch(() => {
if (request.mode === 'navigate') {
return new Response('<!doctype html><meta charset="utf-8"><title>Media Max</title><style>body{margin:0;padding:2rem;background:#181818;color:#ddd;font:16px system-ui}main{max-width:36rem;margin:auto}h1{color:#f4c430}</style><main><h1>Media Max</h1><p>Die Verbindung ist momentan unterbrochen. Bitte erneut laden.</p></main>', {headers: {'Content-Type': 'text/html; charset=utf-8'}});
}
return caches.match(request).then(response => response || new Response('', {status: 503}));
}));
});