diff --git a/src/backupintegrity.js b/src/backupintegrity.js index 2e791ec4f..dae9f521c 100644 --- a/src/backupintegrity.js +++ b/src/backupintegrity.js @@ -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);