Cleanup remote backup controllers
This commit is contained in:
parent
1ce6d3bbba
commit
00429c3911
2 changed files with 8 additions and 19 deletions
|
@ -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 = [
|
||||
|
|
|
@ -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,15 +84,14 @@ 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));
|
||||
}
|
||||
}
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue