Skip to content

Commit 531d3bb

Browse files
committed
Add Canceled status to ScheduleStatus enum and update related logic in useSchedules and backupUtils
1 parent 6952012 commit 531d3bb

9 files changed

Lines changed: 11 additions & 24 deletions

File tree

src/Octockup.Server/Jobs/BackupRunner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,15 +491,15 @@ private async Task HandleCancellationAsync(Schedule schedule, ScheduleReport rep
491491
{
492492
logger.LogInformation("Schedule {ScheduleId} backup canceled", schedule.Id);
493493

494-
schedule.Status = ScheduleStatus.Canceled;
494+
schedule.Status = ScheduleStatus.Failed;
495495
schedule.ErrorMessage = "Backup was canceled.";
496496
schedule.FinishedAt = DateTime.UtcNow;
497497
await dbContext.SaveChangesAsync(CancellationToken.None);
498498

499499
await report.SendAsync(
500500
report.Processed,
501501
"Backup canceled.",
502-
status: ScheduleStatus.Canceled,
502+
status: ScheduleStatus.Failed,
503503
cancellationToken: CancellationToken.None);
504504
}
505505

src/Octockup.Server/Models/Enums/ScheduleStatus.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ public enum ScheduleStatus
99
Running = 1,
1010
Failed = 2,
1111
Completed = 3,
12-
Canceled = 4
1312
}
1413
}

src/octockup.client/src/components/ScheduleCard.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ function getStatusIcon(status: BackupStatus) {
3535
return <CheckCircle sx={{ color: "success.main" }} />;
3636
case BackupStatus.Failed:
3737
return <ErrorOutline sx={{ color: "error.main" }} />;
38-
case BackupStatus.Canceled:
39-
return <StopCircle sx={{ color: "warning.main" }} />;
4038
case BackupStatus.Running:
4139
return <Pending sx={{ color: "info.main" }} />;
4240
case BackupStatus.Created:
@@ -98,8 +96,6 @@ export function ScheduleCard({
9896
? theme.palette.success.main
9997
: item.status === BackupStatus.Failed
10098
? theme.palette.error.main
101-
: item.status === BackupStatus.Canceled
102-
? theme.palette.warning.main
10399
: item.status === BackupStatus.Running
104100
? theme.palette.info.main
105101
: theme.palette.warning.main

src/octockup.client/src/components/backups/BackupStatusChip.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ export function BackupStatusChip({
3636
if (status === "failed") {
3737
const failedSchedule = (backup.schedules || []).find(
3838
(schedule) =>
39-
(schedule.status === BackupStatus.Failed ||
40-
schedule.status === BackupStatus.Canceled) &&
41-
schedule.errorMessage,
39+
schedule.status === BackupStatus.Failed && schedule.errorMessage,
4240
);
4341
errorMessage = failedSchedule?.errorMessage || t("backups.unknownError");
4442
}

src/octockup.client/src/locales/en.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@
212212
"created": "Created",
213213
"running": "Running",
214214
"failed": "Failed",
215-
"completed": "Completed",
216-
"canceled": "Canceled"
215+
"completed": "Completed"
217216
},
218217
"nextRun": {
219218
"label": "Next run",

src/octockup.client/src/locales/ru.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,10 @@
233233
"intervalDays": "каждые {{count}} дн.",
234234
"intervalMinutes": "каждые {{count}} мин",
235235
"status": {
236-
"created": "Создано",
236+
"created": "Ожидает",
237237
"running": "Выполняется",
238238
"failed": "Ошибка",
239-
"completed": "Завершено",
240-
"canceled": "Отменено"
239+
"completed": "Завершено"
241240
},
242241
"nextRun": {
243242
"label": "След. запуск",

src/octockup.client/src/types/api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export enum BackupStatus {
8383
Running = 1,
8484
Failed = 2,
8585
Completed = 3,
86-
Canceled = 4,
8786
}
8887

8988
export interface ScheduleItem {

src/octockup.client/src/utils/backupUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export function getBackupOverallStatus(
7777
}
7878

7979
// Check schedules from backup.schedules (persistent data)
80+
// Only consider Failed schedules that have actual errors
8081
const finishedSchedules = (backup.schedules || []).filter(
8182
(schedule) => schedule.finishedAt,
8283
);
@@ -90,12 +91,11 @@ export function getBackupOverallStatus(
9091
return scheduleFinishTime > snapshotTime;
9192
});
9293

93-
// Priority 4: Warning - has successful snapshot, but schedule failed after it
94+
// Priority 4: Warning - has successful snapshot, but schedule failed after it WITH ERROR
95+
// Failed without errorMessage don't indicate problems
9496
const hasFailedScheduleAfterSnapshot = schedulesAfterSnapshot.some(
9597
(schedule) =>
96-
(schedule.status === BackupStatus.Failed ||
97-
schedule.status === BackupStatus.Canceled) &&
98-
schedule.errorMessage,
98+
schedule.status === BackupStatus.Failed && schedule.errorMessage,
9999
);
100100

101101
if (hasFailedScheduleAfterSnapshot) {

src/octockup.client/src/utils/scheduleUtils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ export function statusColor(
1212
return "info";
1313
case BackupStatus.Failed:
1414
return "error";
15-
case BackupStatus.Canceled:
16-
return "warning";
1715
case BackupStatus.Created:
1816
default:
1917
return "default";
@@ -97,8 +95,7 @@ export function calculateNextRunTime(
9795
if (
9896
item.finishedAt &&
9997
(item.status === BackupStatus.Completed ||
100-
item.status === BackupStatus.Failed ||
101-
item.status === BackupStatus.Canceled)
98+
item.status === BackupStatus.Failed)
10299
) {
103100
const finishedAt = parseUtcDate(item.finishedAt);
104101
if (finishedAt) {

0 commit comments

Comments
 (0)