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

Safari does not support it
pull/451/head
Georgi Gerganov 2 years ago
parent 02c7516c57
commit 60337f5306
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735

File diff suppressed because one or more lines are too long

@ -88,11 +88,15 @@ async function fetchRemote(url, cbProgress, cbPrint) {
// - check if the data is already in the IndexedDB // - check if the data is already in the IndexedDB
// - if not, fetch it from the remote URL and store it 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) { function loadRemote(url, dst, size_mb, cbProgress, cbReady, cbCancel, cbPrint) {
// query the storage quota and print it if (!navigator.storage || !navigator.storage.estimate) {
navigator.storage.estimate().then(function (estimate) { cbPrint('loadRemote: navigator.storage.estimate() is not supported');
cbPrint('loadRemote: storage quota: ' + estimate.quota + ' bytes'); } else {
cbPrint('loadRemote: storage usage: ' + estimate.usage + ' bytes'); // 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 // check if the data is already in the IndexedDB
var rq = indexedDB.open(dbName, dbVersion); var rq = indexedDB.open(dbName, dbVersion);

Loading…
Cancel
Save