diff --git a/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php b/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php index 4bf2f8c09..497d12904 100644 --- a/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php +++ b/app/Http/Controllers/Api/Remote/Backups/BackupRemoteUploadController.php @@ -6,9 +6,7 @@ use Carbon\CarbonImmutable; use Illuminate\Http\Request; use Pterodactyl\Models\Backup; use Illuminate\Http\JsonResponse; -use Illuminate\Foundation\Application; use League\Flysystem\AwsS3v3\AwsS3Adapter; -use Illuminate\Contracts\Config\Repository; use Pterodactyl\Http\Controllers\Controller; use Pterodactyl\Extensions\Backups\BackupManager; use Pterodactyl\Repositories\Eloquent\BackupRepository; @@ -18,11 +16,6 @@ class BackupRemoteUploadController extends Controller { const PART_SIZE = 5 * 1024 * 1024 * 1024; - /** - * @var \Illuminate\Contracts\Config\Repository - */ - protected $config; - /** * @var \Pterodactyl\Repositories\Eloquent\BackupRepository */ @@ -36,13 +29,11 @@ class BackupRemoteUploadController extends Controller /** * BackupRemoteUploadController constructor. * - * @param \Illuminate\Foundation\Application $app * @param \Pterodactyl\Repositories\Eloquent\BackupRepository $repository * @param \Pterodactyl\Extensions\Backups\BackupManager $backupManager */ - public function __construct(Application $app, BackupRepository $repository, BackupManager $backupManager) + public function __construct(BackupRepository $repository, BackupManager $backupManager) { - $this->config = $app->make(Repository::class); $this->repository = $repository; $this->backupManager = $backupManager; } @@ -86,7 +77,7 @@ class BackupRemoteUploadController extends Controller // Get the S3 client $client = $adapter->getClient(); - $expires = CarbonImmutable::now()->addMinutes($this->config->get('backups.presigned_url_lifespan', 60)); + $expires = CarbonImmutable::now()->addMinutes(config('backups.presigned_url_lifespan', 60)); // Params for generating the presigned urls $params = [ diff --git a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php index dac94f8d5..ba98b56f9 100644 --- a/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php +++ b/app/Http/Controllers/Api/Remote/Backups/BackupStatusController.php @@ -60,7 +60,6 @@ class BackupStatusController extends Controller $successful = $request->input('successful') ? true : false; - // TODO: Still run s3 code even if this fails. $model->forceFill([ 'is_successful' => $successful, 'checksum' => $successful ? ($request->input('checksum_type') . ':' . $request->input('checksum')) : null, @@ -85,14 +84,13 @@ class BackupStatusController extends Controller // If the backup was not successful, send an AbortMultipartUpload request. if (! $successful) { $client->execute($client->getCommand('AbortMultipartUpload', $params)); - return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT); + } else { + // Otherwise send a CompleteMultipartUpload request. + $params['MultipartUpload'] = [ + 'Parts' => $client->execute($client->getCommand('ListParts', $params))['Parts'], + ]; + $client->execute($client->getCommand('CompleteMultipartUpload', $params)); } - - // Otherwise send a CompleteMultipartUpload request. - $params['MultipartUpload'] = [ - 'Parts' => $client->execute($client->getCommand('ListParts', $params))['Parts'], - ]; - $client->execute($client->getCommand('CompleteMultipartUpload', $params)); } return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);