From 7b8322e9c9ff978d4a608a6c85dd0c59f5fb16a6 Mon Sep 17 00:00:00 2001 From: Gonzalo Chavez Date: Wed, 11 Nov 2020 10:52:28 -0300 Subject: [PATCH] Backup Rotation - Minor changes --- app/Services/Backups/InitiateBackupService.php | 16 ++++++++-------- .../server/schedules/TaskDetailsModal.tsx | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Services/Backups/InitiateBackupService.php b/app/Services/Backups/InitiateBackupService.php index 3246328c9..aa53b88ae 100644 --- a/app/Services/Backups/InitiateBackupService.php +++ b/app/Services/Backups/InitiateBackupService.php @@ -116,16 +116,16 @@ class InitiateBackupService } // Check if the server has reached or exceeded it's backup limit - if (! $server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) { - if($override) { - // Remove latest backup - $last_backup = $server->backups()->where('is_successful', true)->oldest()->first(); - $this->deleteBackupService->handle($last_backup); - } else { - // Do not allow the user to continue if this server is already at its limit. + if (!$server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) { + // Do not allow the user to continue if this server is already at its limit and can't override. + if (!$override || $server->backup_limit <= 0) { throw new TooManyBackupsException($server->backup_limit); } - } + + // Remove latest backup + $lastBackup = $server->backups()->where('is_successful', true)->orderByDesc('created_at')->first(); + $this->deleteBackupService->handle($lastBackup); + } return $this->connection->transaction(function () use ($server, $name) { /** @var \Pterodactyl\Models\Backup $backup */ diff --git a/resources/scripts/components/server/schedules/TaskDetailsModal.tsx b/resources/scripts/components/server/schedules/TaskDetailsModal.tsx index 65c647219..08f33b161 100644 --- a/resources/scripts/components/server/schedules/TaskDetailsModal.tsx +++ b/resources/scripts/components/server/schedules/TaskDetailsModal.tsx @@ -91,7 +91,7 @@ const TaskDetailsForm = ({ isEditingTask }: { isEditingTask: boolean }) => {