Skip to content

Commit

Permalink
feat(websql): retry a failed setItem caused by Quota error
Browse files Browse the repository at this point in the history
  • Loading branch information
thgreasi committed Jan 30, 2017
1 parent 02f0c83 commit 22a68b6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/drivers/websql.js
Expand Up @@ -137,7 +137,7 @@ function iterate(iterator, callback) {
return promise;
}

function setItem(key, value, callback) {
function _setItem(key, value, callback, retriesLeft) {
var self = this;

// Cast the key to a string, as that's all we can set as a key.
Expand Down Expand Up @@ -183,7 +183,11 @@ function setItem(key, value, callback) {
// more storage on Safari, this error will
// be called.
//
// TODO: Try to re-run the transaction.
// Try to re-run the transaction.
if (retriesLeft > 0) {
resolve(_setItem.apply(self, [key, originalValue, callback, retriesLeft - 1]));
return;
}
reject(sqlError);
}
});
Expand All @@ -196,6 +200,10 @@ function setItem(key, value, callback) {
return promise;
}

function setItem(key, value, callback) {
return _setItem.apply(this, [key, value, callback, 1]);
}

function removeItem(key, callback) {
var self = this;

Expand Down

0 comments on commit 22a68b6

Please sign in to comment.