Use more standardized phpcs
This commit is contained in:
parent
a043071e3c
commit
c449ca5155
493 changed files with 1116 additions and 3903 deletions
|
@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
|||
|
||||
class BackupRemoteUploadController extends Controller
|
||||
{
|
||||
const PART_SIZE = 5 * 1024 * 1024 * 1024;
|
||||
public const PART_SIZE = 5 * 1024 * 1024 * 1024;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\BackupRepository
|
||||
|
@ -29,9 +29,6 @@ class BackupRemoteUploadController extends Controller
|
|||
|
||||
/**
|
||||
* BackupRemoteUploadController constructor.
|
||||
*
|
||||
* @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository
|
||||
* @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager
|
||||
*/
|
||||
public function __construct(BackupRepository $repository, BackupManager $backupManager)
|
||||
{
|
||||
|
@ -42,9 +39,6 @@ class BackupRemoteUploadController extends Controller
|
|||
/**
|
||||
* Returns the required presigned urls to upload a backup to S3 cloud storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string $backup
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*
|
||||
* @throws \Exception
|
||||
|
@ -64,13 +58,13 @@ class BackupRemoteUploadController extends Controller
|
|||
|
||||
// Prevent backups that have already been completed from trying to
|
||||
// be uploaded again.
|
||||
if (! is_null($backup->completed_at)) {
|
||||
if (!is_null($backup->completed_at)) {
|
||||
throw new ConflictHttpException('This backup is already in a completed state.');
|
||||
}
|
||||
|
||||
// Ensure we are using the S3 adapter.
|
||||
$adapter = $this->backupManager->adapter();
|
||||
if (! $adapter instanceof AwsS3Adapter) {
|
||||
if (!$adapter instanceof AwsS3Adapter) {
|
||||
throw new BadRequestHttpException('The configured backup adapter is not an S3 compatible adapter.');
|
||||
}
|
||||
|
||||
|
@ -97,9 +91,10 @@ class BackupRemoteUploadController extends Controller
|
|||
|
||||
// Create as many UploadPart presigned urls as needed
|
||||
$parts = [];
|
||||
for ($i = 0; $i < ($size / self::PART_SIZE); $i++) {
|
||||
for ($i = 0; $i < ($size / self::PART_SIZE); ++$i) {
|
||||
$parts[] = $client->createPresignedRequest(
|
||||
$client->getCommand('UploadPart', array_merge($params, ['PartNumber' => $i + 1])), $expires
|
||||
$client->getCommand('UploadPart', array_merge($params, ['PartNumber' => $i + 1])),
|
||||
$expires
|
||||
)->getUri()->__toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,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)
|
||||
{
|
||||
|
@ -40,8 +37,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 \Exception
|
||||
|
@ -51,10 +46,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.');
|
||||
}
|
||||
|
||||
$successful = $request->input('successful') ? true : false;
|
||||
|
@ -80,10 +73,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
|
||||
*/
|
||||
|
@ -95,7 +84,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.');
|
||||
|
@ -108,7 +97,7 @@ class BackupStatusController extends Controller
|
|||
];
|
||||
|
||||
$client = $adapter->getClient();
|
||||
if (! $successful) {
|
||||
if (!$successful) {
|
||||
$client->execute($client->getCommand('AbortMultipartUpload', $params));
|
||||
|
||||
return;
|
||||
|
|
Reference in a new issue