Automatically reopen DB when closed (e.g. due to SW update)

pull/452/head^2
Zef Hemel 2023-07-07 15:45:52 +02:00
parent fd6f81d500
commit e98495fb50
1 changed files with 5 additions and 0 deletions

View File

@ -118,6 +118,11 @@ async function handleLocalFileRequest(
// Not initialzed yet, or explicitly in sync mode (so direct server communication requested)
return fetch(request);
}
if (!db?.isOpen()) {
console.log("Detected that the DB was closed, reopening");
await db!.open();
}
const path = decodeURIComponent(pathname.slice(1));
const data = await fileContentTable.get(path);
if (data) {