Skip to content

Commit a4172a7

Browse files
committed
StorageUtils: improve display
1 parent b1fb2ae commit a4172a7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/common/util/storageUtils.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ export async function requestPersistentStorageSafe(): Promise<boolean> {
1717
}
1818

1919
const isGranted = await navigator.storage.persist();
20-
if (DEBUG_PERSISTENCE || !isGranted)
21-
console.warn('Persistent storage granted', isGranted, /*await navigator.storage.getDirectory(),*/ await estimatePersistentStorageOrThrow());
20+
if (DEBUG_PERSISTENCE || !isGranted) {
21+
// await navigator.storage.getDirectory()
22+
const estimate = await estimatePersistentStorageOrThrow();
23+
console.warn('Persistent storage granted:', isGranted, 'usageMB:', estimate?.usageMB, 'quotaMB:', estimate?.quotaMB);
24+
}
2225
return isGranted;
2326
}
2427
} catch (error) {
@@ -36,7 +39,7 @@ export async function estimatePersistentStorageOrThrow(): Promise<{ usageMB: num
3639
return {
3740
// convert to MBs (with 3 decimal places)
3841
usageMB: Math.round((estimate.usage || 0) / 1024 / 1024 * 1000) / 1000,
39-
quotaMB: Math.round((estimate.quota || 0) / 1024 / 1024 * 1000) / 1000,
42+
quotaMB: Math.round((estimate.quota || 0) / 1024 / 1024),
4043
};
4144
}
4245

0 commit comments

Comments
 (0)