Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #654 from thgreasi/websqlDbQuotaRetry
feat(websql): retry a failed setItem caused by Quota error
- Loading branch information
Showing
7 changed files
with
148 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf8" /> | ||
<title>Simple localForage example</title> | ||
</head> | ||
<body> | ||
<script src="../dist/localforage.js"></script> | ||
<script> | ||
// Forcing WEBSQL here. Feel free to switch to other drivers :) | ||
localforage.setDriver(localforage.WEBSQL).then(function() { | ||
return localforage.ready(); | ||
}).then(() => { | ||
console.log('ready: ' + localforage.driver()); | ||
}).then(() => { | ||
var overall = Promise.resolve(); | ||
for (let i = 0; i < 1; i++) { | ||
overall = overall.then(() => { | ||
return wait(2000).then(() => (+new Date()) / 1000 | 0); | ||
}).then((timestamp) => { | ||
var data = new Uint32Array(2*1024*1024); | ||
data[0] = timestamp; | ||
return localforage.setItem(`bigdata${i}`, data).then( | ||
data => console.log(`setItem${i} resolved`, data[0]), | ||
e => { | ||
console.log(`setItem${i} rejected`, e); | ||
return Promise.reject(e); | ||
}).then(() => { | ||
return localforage.getItem(`bigdata${i}`); | ||
}).then( | ||
data => { | ||
if (data && data[0] === timestamp) { | ||
console.log(`getItem${i} data matches`, data[0]); | ||
} else { | ||
console.log(`getItem${i} data missmatch`, timestamp, data[0]); | ||
} | ||
}, | ||
e => { | ||
console.log('rejected', e); | ||
return Promise.reject(e); | ||
}); | ||
}); | ||
} | ||
return overall; | ||
}).then( | ||
() => console.log('all done'), | ||
e => console.log('Error', e)); | ||
|
||
function wait(ms) { | ||
return new Promise(function(resolve) { | ||
resolve(); | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters