backuptask: track copy and upload statistics
This commit is contained in:
+4
-10
@@ -6,7 +6,6 @@ exports = module.exports = {
|
||||
getLatestInTargetByIdentifier, // brutal function name
|
||||
add,
|
||||
update,
|
||||
setState,
|
||||
list,
|
||||
listBySiteId,
|
||||
listByTypePaged,
|
||||
@@ -147,9 +146,12 @@ async function update(backup, data) {
|
||||
|
||||
const fields = [], values = [];
|
||||
for (const p in data) {
|
||||
if (p === 'label' || p === 'preserveSecs') {
|
||||
if (p === 'label' || p === 'preserveSecs' || p === 'state') {
|
||||
fields.push(p + ' = ?');
|
||||
values.push(data[p]);
|
||||
} else if (p === 'stats') {
|
||||
fields.push(`${p}Json=?`);
|
||||
values.push(JSON.stringify(data[p]));
|
||||
}
|
||||
}
|
||||
values.push(backup.id);
|
||||
@@ -165,14 +167,6 @@ async function update(backup, data) {
|
||||
}
|
||||
}
|
||||
|
||||
async function setState(id, state) {
|
||||
assert.strictEqual(typeof id, 'string');
|
||||
assert.strictEqual(typeof state, 'string');
|
||||
|
||||
const result = await database.query('UPDATE backups SET state = ? WHERE id = ?', [state, id]);
|
||||
if (result.affectedRows !== 1) throw new BoxError(BoxError.NOT_FOUND, 'Backup not found');
|
||||
}
|
||||
|
||||
async function list(page, perPage) {
|
||||
assert(typeof page === 'number' && page > 0);
|
||||
assert(typeof perPage === 'number' && perPage > 0);
|
||||
|
||||
Reference in New Issue
Block a user