Merge branch 'develop' into dane/restore-backups

This commit is contained in:
Dane Everitt 2021-01-25 19:16:40 -08:00
commit 663143de0b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
575 changed files with 6080 additions and 6864 deletions

View file

@ -35,11 +35,6 @@ class DeleteBackupService
/**
* DeleteBackupService constructor.
*
* @param \Illuminate\Database\ConnectionInterface $connection
* @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository
* @param \Pterodactyl\Extensions\Backups\BackupManager $manager
* @param \Pterodactyl\Repositories\Wings\DaemonBackupRepository $daemonBackupRepository
*/
public function __construct(
ConnectionInterface $connection,
@ -56,7 +51,6 @@ class DeleteBackupService
/**
* Deletes a backup from the system.
*
* @param \Pterodactyl\Models\Backup $backup
* @throws \Throwable
*/
public function handle(Backup $backup)
@ -74,7 +68,7 @@ class DeleteBackupService
$previous = $exception->getPrevious();
// Don't fail the request if the Daemon responds with a 404, just assume the backup
// doesn't actually exist and remove it's reference from the Panel as well.
if (! $previous instanceof ClientException || $previous->getResponse()->getStatusCode() !== Response::HTTP_NOT_FOUND) {
if (!$previous instanceof ClientException || $previous->getResponse()->getStatusCode() !== Response::HTTP_NOT_FOUND) {
throw $exception;
}
}
@ -86,7 +80,6 @@ class DeleteBackupService
/**
* Deletes a backup from an S3 disk.
*
* @param \Pterodactyl\Models\Backup $backup
* @throws \Throwable
*/
protected function deleteFromS3(Backup $backup)

View file

@ -49,11 +49,7 @@ class InitiateBackupService
/**
* InitiateBackupService constructor.
*
* @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository
* @param \Illuminate\Database\ConnectionInterface $connection
* @param \Pterodactyl\Repositories\Wings\DaemonBackupRepository $daemonBackupRepository
* @param \Pterodactyl\Services\Backups\DeleteBackupService $deleteBackupService
* @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager
*/
public function __construct(
BackupRepository $repository,
@ -73,6 +69,7 @@ class InitiateBackupService
* Sets the files to be ignored by this backup.
*
* @param string[]|null $ignored
*
* @return $this
*/
public function setIgnoredFiles(?array $ignored)
@ -96,12 +93,6 @@ class InitiateBackupService
/**
* Initiates the backup process for a server on the daemon.
*
* @param \Pterodactyl\Models\Server $server
* @param string|null $name
* @param bool $override
*
* @return \Pterodactyl\Models\Backup
*
* @throws \Throwable
* @throws \Pterodactyl\Exceptions\Service\Backup\TooManyBackupsException
* @throws \Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException
@ -113,17 +104,14 @@ class InitiateBackupService
if ($period > 0) {
$previous = $this->repository->getBackupsGeneratedDuringTimespan($server->id, $period);
if ($previous->count() >= $limit) {
throw new TooManyRequestsHttpException(
CarbonImmutable::now()->diffInSeconds($previous->last()->created_at->addSeconds($period)),
sprintf('Only %d backups may be generated within a %d second span of time.', $limit, $period)
);
throw new TooManyRequestsHttpException(CarbonImmutable::now()->diffInSeconds($previous->last()->created_at->addSeconds($period)), sprintf('Only %d backups may be generated within a %d second span of time.', $limit, $period));
}
}
// 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 (!$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) {
if (!$override || $server->backup_limit <= 0) {
throw new TooManyBackupsException($server->backup_limit);
}