ggerganov commited on
Commit
3564c33
·
unverified ·
1 Parent(s): 89e8314

wasm : check if navigator.storage.estimate() is available

Browse files
bindings/javascript/whisper.js CHANGED
The diff for this file is too large to render. See raw diff
 
examples/helpers.js CHANGED
@@ -88,11 +88,15 @@ async function fetchRemote(url, cbProgress, cbPrint) {
88
  // - check if the data is already in the IndexedDB
89
  // - if not, fetch it from the remote URL and store it in the IndexedDB
90
  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
- });
 
 
 
 
96
 
97
  // check if the data is already in the IndexedDB
98
  var rq = indexedDB.open(dbName, dbVersion);
 
88
  // - check if the data is already in the IndexedDB
89
  // - if not, fetch it from the remote URL and store it in the IndexedDB
90
  function loadRemote(url, dst, size_mb, cbProgress, cbReady, cbCancel, cbPrint) {
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
+ }
100
 
101
  // check if the data is already in the IndexedDB
102
  var rq = indexedDB.open(dbName, dbVersion);