Skip to content

Commit

Permalink
wasm : check if navigator.storage.estimate() is available
Browse files Browse the repository at this point in the history
Safari does not support it
  • Loading branch information
ggerganov committed Jan 25, 2023
1 parent 02c7516 commit 60337f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bindings/javascript/whisper.js

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions examples/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ async function fetchRemote(url, cbProgress, cbPrint) {
// - check if the data is already in the IndexedDB
// - if not, fetch it from the remote URL and store it in the IndexedDB
function loadRemote(url, dst, size_mb, cbProgress, cbReady, cbCancel, cbPrint) {
// query the storage quota and print it
navigator.storage.estimate().then(function (estimate) {
cbPrint('loadRemote: storage quota: ' + estimate.quota + ' bytes');
cbPrint('loadRemote: storage usage: ' + estimate.usage + ' bytes');
});
if (!navigator.storage || !navigator.storage.estimate) {
cbPrint('loadRemote: navigator.storage.estimate() is not supported');
} else {
// query the storage quota and print it
navigator.storage.estimate().then(function (estimate) {
cbPrint('loadRemote: storage quota: ' + estimate.quota + ' bytes');
cbPrint('loadRemote: storage usage: ' + estimate.usage + ' bytes');
});
}

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

0 comments on commit 60337f5

Please sign in to comment.