fix(backup): retry wont be scheduled if it is after the next scheduled backup

This commit is contained in:
DerPenz 2026-04-10 14:51:20 +02:00 committed by Nico
parent 5d8c2925d8
commit 11bb95db92

View file

@ -225,15 +225,15 @@ export async function handleBackupFailure(
const currentRetryCount = schedule.failureRetryCount;
const maxRetries = schedule.maxRetries;
const shouldRetry = currentRetryCount < maxRetries;
const nextRetryBackupAt = Date.now() + schedule.retryDelay;
const nextScheduledBackupAt = calculateNextRun(schedule.cronExpression);
if (shouldRetry) {
const nextBackupAt = Date.now() + schedule.retryDelay;
if (shouldRetry && nextRetryBackupAt < nextScheduledBackupAt) {
await scheduleQueries.updateStatus(scheduleId, organizationId, {
lastBackupAt: Date.now(),
lastBackupStatus: "error",
lastBackupError: errorDetails,
nextBackupAt,
nextBackupAt: nextRetryBackupAt,
failureRetryCount: currentRetryCount + 1,
});
@ -292,8 +292,8 @@ export async function handleBackupFailure(
scheduleName: schedule.name,
error: `${errorDetails}\n\nFailed after ${maxRetries} retry attempts.`,
})
.catch((notifError) => {
logger.error(`Failed to send backup failure notification: ${toMessage(notifError)}`);
.catch((notifyError) => {
logger.error(`Failed to send backup failure notification: ${toMessage(notifyError)}`);
});
}