Delete the oldest backup, not the newest backup, closes #2800
This commit is contained in:
parent
63eefaa695
commit
911d85c230
1 changed files with 5 additions and 3 deletions
|
@ -13,7 +13,6 @@ use Pterodactyl\Repositories\Eloquent\BackupRepository;
|
||||||
use Pterodactyl\Repositories\Wings\DaemonBackupRepository;
|
use Pterodactyl\Repositories\Wings\DaemonBackupRepository;
|
||||||
use Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException;
|
use Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException;
|
||||||
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
|
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
|
||||||
use Pterodactyl\Services\Backups\DeleteBackupService;
|
|
||||||
|
|
||||||
class InitiateBackupService
|
class InitiateBackupService
|
||||||
{
|
{
|
||||||
|
@ -124,8 +123,11 @@ class InitiateBackupService
|
||||||
throw new TooManyBackupsException($server->backup_limit);
|
throw new TooManyBackupsException($server->backup_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove oldest backup
|
// Get the oldest backup the server has.
|
||||||
$oldestBackup = $server->backups()->where('is_successful', true)->orderByDesc('created_at')->first();
|
/** @var \Pterodactyl\Models\Backup $oldestBackup */
|
||||||
|
$oldestBackup = $server->backups()->where('is_successful', true)->orderBy('created_at')->first();
|
||||||
|
|
||||||
|
// Delete the oldest backup.
|
||||||
$this->deleteBackupService->handle($oldestBackup);
|
$this->deleteBackupService->handle($oldestBackup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue