mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-19 23:03:45 +02:00
backend: support is_successful state for backups rather than deleting it when failing
This allows the UI to correctly show failed backups to the user and require them to manually delete those backups, rather than them mysteriously disappearing. We can also hook into this later to send a notification to the user when the backup fails.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Pterodactyl\Services\Backups;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Webmozart\Assert\Assert;
|
||||
@@ -101,14 +100,14 @@ class InitiateBackupService
|
||||
public function handle(Server $server, string $name = null): Backup
|
||||
{
|
||||
// Do not allow the user to continue if this server is already at its limit.
|
||||
if (! $server->backup_limit || $server->backups()->count() >= $server->backup_limit) {
|
||||
if (! $server->backup_limit || $server->backups()->where('is_successful', true)->count() >= $server->backup_limit) {
|
||||
throw new TooManyBackupsException($server->backup_limit);
|
||||
}
|
||||
|
||||
$previous = $this->repository->getBackupsGeneratedDuringTimespan($server->id, 10);
|
||||
if ($previous->count() >= 2) {
|
||||
throw new TooManyRequestsHttpException(
|
||||
Carbon::now()->diffInSeconds($previous->last()->created_at->addMinutes(10)),
|
||||
CarbonImmutable::now()->diffInSeconds($previous->last()->created_at->addMinutes(10)),
|
||||
'Only two backups may be generated within a 10 minute span of time.'
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user