backuptask: track copy and upload statistics

This commit is contained in:
Girish Ramakrishnan
2025-10-20 13:22:51 +02:00
parent 854661e2d4
commit 07732310c1
7 changed files with 52 additions and 41 deletions
+4 -10
View File
@@ -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);