backupintegrity: add percent progress
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user