Skip to content

Commit 60337f5

Browse files
committed
wasm : check if navigator.storage.estimate() is available
Safari does not support it
1 parent 02c7516 commit 60337f5

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

bindings/javascript/whisper.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/helpers.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,15 @@ async function fetchRemote(url, cbProgress, cbPrint) {
8888
// - check if the data is already in the IndexedDB
8989
// - if not, fetch it from the remote URL and store it in the IndexedDB
9090
function loadRemote(url, dst, size_mb, cbProgress, cbReady, cbCancel, cbPrint) {
91-
// query the storage quota and print it
92-
navigator.storage.estimate().then(function (estimate) {
93-
cbPrint('loadRemote: storage quota: ' + estimate.quota + ' bytes');
94-
cbPrint('loadRemote: storage usage: ' + estimate.usage + ' bytes');
95-
});
91+
if (!navigator.storage || !navigator.storage.estimate) {
92+
cbPrint('loadRemote: navigator.storage.estimate() is not supported');
93+
} else {
94+
// query the storage quota and print it
95+
navigator.storage.estimate().then(function (estimate) {
96+
cbPrint('loadRemote: storage quota: ' + estimate.quota + ' bytes');
97+
cbPrint('loadRemote: storage usage: ' + estimate.usage + ' bytes');
98+
});
99+
}
96100

97101
// check if the data is already in the IndexedDB
98102
var rq = indexedDB.open(dbName, dbVersion);

0 commit comments

Comments
 (0)