web/storage: catch the missing dir error

This commit is contained in:
wukko 2025-02-02 01:08:07 +06:00
parent 61efa619a2
commit 19a342457b
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -54,7 +54,13 @@ export const removeFromFileStorage = async (filename: string) => {
}
export const clearFileStorage = async () => {
const root = await navigator.storage.getDirectory();
return await root.removeEntry(cobaltProcessingDir, { recursive: true });
if (navigator.storage.getDirectory) {
const root = await navigator.storage.getDirectory();
try {
await root.removeEntry(cobaltProcessingDir, { recursive: true });
} catch {
// ignore the error because the dir might be missing and that's okay!
}
}
}