Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #166 from crdlc/bug-1071525
Browse files Browse the repository at this point in the history
Bug 1071525 - [Loop] Closing Loop app revoke all the shared URL's
  • Loading branch information
Cristian Rodriguez committed Oct 10, 2014
2 parents 80ccf4f + fcb7f58 commit 1156718
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion js/controller.js
Expand Up @@ -247,7 +247,7 @@
callback();
}
},
date
token
);
},
function onError(e) {
Expand Down
56 changes: 28 additions & 28 deletions js/helpers/action_log_db.js
Expand Up @@ -354,52 +354,47 @@
}, 'readonly', [aObjectStore]);
}

function _updateRecord(aCallback, aObjectStore, aIndex, aRecord) {
function _updateRecord(aCallback, aObjectStore, aFilter, aRecord) {
_checkCallback(aCallback);

if (!_isValidRecord(aObjectStore, aRecord)) {
aCallback('INVALID_RECORD');
return;
}

_newTxn(function(error, txn, store) {
var onRecord = function(error, record) {
if (error) {
aCallback(error);
return;
}

var count = 0;
var req;
if (aIndex) {
if (!store.indexNames.contains(aIndex)) {
aCallback('INVALID_INDEX_NAME');
return;
}
req = store.index(aIndex).openCursor();
} else {
req = store.openCursor();
if (!record) {
aCallback('NOT_FOUND');
return;
}

req.onsuccess = function onsuccess(event) {
var cursor = event.target.result;
if (!cursor) {
aCallback(null, count);
_newTxn(function(error, txn, store) {
if (error) {
aCallback(error);
return;
}

var record = cursor.value;
Object.keys(aRecord).forEach(function(key) {
Object.keys(aRecord).forEach((key) => {
record[key] = aRecord[key];
});

cursor.update(record);
count++;
cursor.continue();
};
req.onerror = function onerror(event) {
aCallback(event.target.error.name);
};
}, 'readwrite', [aObjectStore]);
var req = store.put(record);
req.onsuccess = function() {
aCallback();
};
req.onerror = function(e) {
console.error('Record not updated', e);
aCallback();
};
}, 'readwrite', [aObjectStore]);
};

_getRecord(onRecord, aObjectStore, aFilter);
}

function _clearObjectStore(aCallback, aObjectStore) {
Expand Down Expand Up @@ -811,8 +806,13 @@
});
},

revokeUrl: function(aCallback, aUrlCreationDate) {
_updateRecord(aCallback, _dbUrlStore, null, { revoked: true });
revokeUrl: function(aCallback, aToken) {
_updateRecord(aCallback, _dbUrlStore, {
index: {
name: 'urlToken',
value: aToken
}
}, { revoked: true });
},

deleteCalls: function(aCallback, aCalls) {
Expand Down
2 changes: 1 addition & 1 deletion js/version.js
@@ -1 +1 @@
Version = { id: '695ba08' };
Version = { id: 'e5ba977' };

0 comments on commit 1156718

Please sign in to comment.