backuptask: fix crash when accessing stats of old backups

This commit is contained in:
Girish Ramakrishnan
2025-10-16 12:32:24 +02:00
parent 9e92d08261
commit 847cb91759
+3 -2
View File
@@ -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);