From 97d0a8694679782e9f3cc8d10bf23d3657128c3c Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Sun, 21 Dec 2025 14:05:15 +0100 Subject: [PATCH] fix(stop): always update status to warning when stop is executed --- app/server/modules/backups/backups.service.ts | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/app/server/modules/backups/backups.service.ts b/app/server/modules/backups/backups.service.ts index 1ff51247..6bcb796b 100644 --- a/app/server/modules/backups/backups.service.ts +++ b/app/server/modules/backups/backups.service.ts @@ -428,23 +428,25 @@ const stopBackup = async (scheduleId: number) => { throw new NotFoundError("Backup schedule not found"); } - const abortController = runningBackups.get(scheduleId); - if (!abortController) { - throw new ConflictError("No backup is currently running for this schedule"); + try { + const abortController = runningBackups.get(scheduleId); + if (!abortController) { + throw new ConflictError("No backup is currently running for this schedule"); + } + + logger.info(`Stopping backup for schedule ${scheduleId}`); + + abortController.abort(); + } finally { + await db + .update(backupSchedulesTable) + .set({ + lastBackupStatus: "warning", + lastBackupError: "Backup was stopped by user", + updatedAt: Date.now(), + }) + .where(eq(backupSchedulesTable.id, scheduleId)); } - - logger.info(`Stopping backup for schedule ${scheduleId}`); - - abortController.abort(); - - await db - .update(backupSchedulesTable) - .set({ - lastBackupStatus: "warning", - lastBackupError: "Backup was stopped by user", - updatedAt: Date.now(), - }) - .where(eq(backupSchedulesTable.id, scheduleId)); }; const runForget = async (scheduleId: number, repositoryId?: string) => {