backups: remove entries from database that don't exist in storage

fixes #772
This commit is contained in:
Girish Ramakrishnan
2021-02-18 16:51:43 -08:00
parent a5c4b5d8a1
commit c4dffa393b
7 changed files with 212 additions and 43 deletions
+16
View File
@@ -18,6 +18,7 @@ exports = module.exports = {
get,
del,
update,
list,
_clear: clear
};
@@ -80,6 +81,21 @@ function getByIdentifierPaged(identifier, page, perPage, callback) {
});
}
function list(page, perPage, callback) {
assert(typeof page === 'number' && page > 0);
assert(typeof perPage === 'number' && perPage > 0);
assert.strictEqual(typeof callback, 'function');
database.query('SELECT ' + BACKUPS_FIELDS + ' FROM backups ORDER BY creationTime DESC LIMIT ?,?',
[ (page-1)*perPage, perPage ], function (error, results) {
if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error));
results.forEach(function (result) { postProcess(result); });
callback(null, results);
});
}
function get(id, callback) {
assert.strictEqual(typeof id, 'string');
assert.strictEqual(typeof callback, 'function');