backuptask: fix crash when accessing stats of old backups
This commit is contained in:
+3
-2
@@ -283,7 +283,8 @@ async function backupBox(backupSite, appBackupsMap, tag, options, progressCallba
|
||||
|
||||
debug(`backupBox: rotating box snapshot of ${backupSite.id} to id ${remotePath}`);
|
||||
|
||||
stats.aggregated = Array.from(appBackupsMap.values()).reduce((acc, s) => ({
|
||||
// stats object might be null for stopped/errored apps from old versions
|
||||
stats.aggregated = Array.from(appBackupsMap.values()).filter(s => !!s).reduce((acc, s) => ({
|
||||
fileCount: acc.fileCount + s.fileCount,
|
||||
size: acc.size + s.size,
|
||||
startTime: Math.min(acc.startTime, s.startTime),
|
||||
@@ -373,7 +374,7 @@ async function backupAppWithTag(app, backupSite, tag, options, progressCallback)
|
||||
if (!apps.canBackupApp(app)) { // if we cannot backup, reuse it's most recent backup
|
||||
const lastKnownGoodAppBackup = await backups.getLatestInTargetByIdentifier(app.id, backupSite.id);
|
||||
if (lastKnownGoodAppBackup === null) return null; // no backup to re-use
|
||||
return lastKnownGoodAppBackup.id;
|
||||
return { id: lastKnownGoodAppBackup.id, stats: lastKnownGoodAppBackup.stats };
|
||||
}
|
||||
|
||||
const { stats, integrity } = await uploadAppSnapshot(backupSite, app, progressCallback);
|
||||
|
||||
Reference in New Issue
Block a user