From 446dc8b33d64e8fb90afb97229f25b3815a9d876 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 26 Apr 2020 12:21:14 -0700 Subject: [PATCH] Block creation of backups if it would put the server over it's limit --- .../Backup/TooManyBackupsException.php | 20 +++++++++++++++++++ .../Backups/InitiateBackupService.php | 8 ++++++++ 2 files changed, 28 insertions(+) create mode 100644 app/Exceptions/Service/Backup/TooManyBackupsException.php diff --git a/app/Exceptions/Service/Backup/TooManyBackupsException.php b/app/Exceptions/Service/Backup/TooManyBackupsException.php new file mode 100644 index 000000000..a96baed50 --- /dev/null +++ b/app/Exceptions/Service/Backup/TooManyBackupsException.php @@ -0,0 +1,20 @@ +backup_limit || $server->backups()->count() >= $server->backup_limit) { + throw new TooManyBackupsException($server->backup_limit); + } + $previous = $this->repository->getBackupsGeneratedDuringTimespan($server->id, 10); if ($previous->count() >= 2) { throw new TooManyRequestsHttpException(