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

@ -9,8 +9,8 @@ use Pterodactyl\Models\Server;
use Pterodactyl\Models\AuditLog;
use Illuminate\Http\JsonResponse;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Extensions\Backups\BackupManager;
use Pterodactyl\Repositories\Eloquent\BackupRepository;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@ -30,9 +30,6 @@ class BackupStatusController extends Controller
/**
* BackupStatusController constructor.
*
* @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository
* @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager
*/
public function __construct(BackupRepository $repository, BackupManager $backupManager)
{
@ -43,8 +40,6 @@ class BackupStatusController extends Controller
/**
* Handles updating the state of a backup.
*
* @param \Pterodactyl\Http\Requests\Api\Remote\ReportBackupCompleteRequest $request
* @param string $backup
* @return \Illuminate\Http\JsonResponse
*
* @throws \Throwable
@ -54,10 +49,8 @@ class BackupStatusController extends Controller
/** @var \Pterodactyl\Models\Backup $model */
$model = Backup::query()->where('uuid', $backup)->firstOrFail();
if (! is_null($model->completed_at)) {
throw new BadRequestHttpException(
'Cannot update the status of a backup that is already marked as completed.'
);
if (!is_null($model->completed_at)) {
throw new BadRequestHttpException('Cannot update the status of a backup that is already marked as completed.');
}
$action = $request->input('successful')
@ -124,10 +117,6 @@ class BackupStatusController extends Controller
* Marks a multipart upload in a given S3-compatiable instance as failed or successful for
* the given backup.
*
* @param \Pterodactyl\Models\Backup $backup
* @param \League\Flysystem\AwsS3v3\AwsS3Adapter $adapter
* @param bool $successful
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\DisplayException
*/
@ -139,7 +128,7 @@ class BackupStatusController extends Controller
// A failed backup doesn't need to error here, this can happen if the backup encouters
// an error before we even start the upload. AWS gives you tooling to clear these failed
// multipart uploads as needed too.
if (! $successful) {
if (!$successful) {
return;
}
throw new DisplayException('Cannot complete backup request: no upload_id present on model.');
@ -152,7 +141,7 @@ class BackupStatusController extends Controller
];
$client = $adapter->getClient();
if (! $successful) {
if (!$successful) {
$client->execute($client->getCommand('AbortMultipartUpload', $params));
return;