mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-28 01:18:27 +00:00
web/storage: make opfs check more robust
This commit is contained in:
parent
893c6edde7
commit
1058014c96
@ -44,7 +44,10 @@ export class OPFSStorage {
|
||||
}
|
||||
|
||||
static isAvailable() {
|
||||
return !!navigator.storage?.getDirectory;
|
||||
if (typeof navigator === 'undefined')
|
||||
return false;
|
||||
|
||||
return 'storage' in navigator && 'getDirectory' in navigator.storage;
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +58,7 @@ export const removeFromFileStorage = async (filename: string) => {
|
||||
}
|
||||
|
||||
export const clearFileStorage = async () => {
|
||||
if (navigator.storage.getDirectory) {
|
||||
if (OPFSStorage.isAvailable()) {
|
||||
const root = await navigator.storage.getDirectory();
|
||||
try {
|
||||
await root.removeEntry(COBALT_PROCESSING_DIR, { recursive: true });
|
||||
|
Loading…
Reference in New Issue
Block a user