Merge branch 'develop' into dane/restore-backups
This commit is contained in:
commit
663143de0b
575 changed files with 6080 additions and 6864 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Reference in a new issue