More fixes

This commit is contained in:
Dane Everitt 2017-10-07 18:08:19 -05:00
parent 17642bffe7
commit c19c423568
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
14 changed files with 67 additions and 61 deletions

View file

@ -54,10 +54,10 @@ class PackUpdateService
public function handle($pack, array $data)
{
if (! $pack instanceof Pack) {
$pack = $this->repository->withColumns(['id', 'option_id'])->find($pack);
$pack = $this->repository->withColumns(['id', 'egg_id'])->find($pack);
}
if ((int) array_get($data, 'option_id', $pack->option_id) !== $pack->option_id) {
if ((int) array_get($data, 'egg_id', $pack->egg_id) !== $pack->egg_id) {
$count = $this->serverRepository->findCountWhere([['pack_id', '=', $pack->id]]);
if ($count !== 0) {

View file

@ -52,7 +52,7 @@ class TemplateUploadService
/**
* Process an uploaded file to create a new pack from a JSON or ZIP format.
*
* @param int $option
* @param int $egg
* @param \Illuminate\Http\UploadedFile $file
* @return \Pterodactyl\Models\Pack
*
@ -63,7 +63,7 @@ class TemplateUploadService
* @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException
*/
public function handle($option, UploadedFile $file)
public function handle($egg, UploadedFile $file)
{
if (! $file->isValid()) {
throw new InvalidFileUploadException(trans('exceptions.packs.invalid_upload'));
@ -76,10 +76,10 @@ class TemplateUploadService
}
if ($file->getMimeType() === 'application/zip') {
return $this->handleArchive($option, $file);
return $this->handleArchive($egg, $file);
} else {
$json = json_decode($file->openFile()->fread($file->getSize()), true);
$json['option_id'] = $option;
$json['egg_id'] = $egg;
return $this->creationService->handle($json);
}
@ -88,7 +88,7 @@ class TemplateUploadService
/**
* Process a ZIP file to create a pack and stored archive.
*
* @param int $option
* @param int $egg
* @param \Illuminate\Http\UploadedFile $file
* @return \Pterodactyl\Models\Pack
*
@ -99,7 +99,7 @@ class TemplateUploadService
* @throws \Pterodactyl\Exceptions\Service\Pack\UnreadableZipArchiveException
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidPackArchiveFormatException
*/
protected function handleArchive($option, $file)
protected function handleArchive($egg, $file)
{
if (! $this->archive->open($file->getRealPath())) {
throw new UnreadableZipArchiveException(trans('exceptions.packs.unreadable'));
@ -110,7 +110,7 @@ class TemplateUploadService
}
$json = json_decode($this->archive->getFromName('import.json'), true);
$json['option_id'] = $option;
$json['egg_id'] = $egg;
$pack = $this->creationService->handle($json);
if (! $this->archive->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) {

View file

@ -124,7 +124,7 @@ class ServerCreationService
public function create(array $data)
{
// @todo auto-deployment
$validator = $this->validatorService->isAdmin()->setFields($data['environment'])->validate($data['option_id']);
$validator = $this->validatorService->isAdmin()->setFields($data['environment'])->validate($data['egg_id']);
$uniqueShort = str_random(8);
$this->connection->beginTransaction();