backupintegrity: add percent progress

This commit is contained in:
Girish Ramakrishnan
2026-03-04 18:30:16 +05:30
parent 5fc9689645
commit fed51bdcd9

View File

@@ -60,16 +60,22 @@ async function check(backupId, progressCallback) {
const backupSite = await backupSites.get(backup.siteId);
if (!backupSite) throw new BoxError(BoxError.BAD_FIELD, 'Backup site not found');
const total = backup.dependsOn.length + 1;
let completed = 0;
const aggregatedStats = { startTime: Date.now(), duration: null };
const aggregatedMessages = [];
for (const depId of backup.dependsOn) {
const depBackup = await backups.get(depId);
progressCallback({ percent: Math.round(completed / total * 100), message: `Verifying ${depBackup.remotePath}` });
const result = await verify(depBackup, backupSite, progressCallback); // { stats, messages }
completed++;
await backups.setIntegrityResult(depBackup, result.messages.length === 0 ? 'passed' : 'failed', result);
if (result.messages.length) aggregatedMessages.push(`Integrity check of dependent backup ${depBackup.remotePath} failed`);
}
progressCallback({ percent: Math.round(completed / total * 100), message: `Verifying ${backup.remotePath}` });
const result = await verify(backup, backupSite, progressCallback);
aggregatedStats.duration = Date.now() - aggregatedStats.startTime;
aggregatedMessages.push(...result.messages);