Add ability to update an Egg by re-uploading a file.
This commit is contained in:
parent
e2cb789b2b
commit
e01d7497f5
17 changed files with 449 additions and 23 deletions
|
@ -15,7 +15,8 @@ use Illuminate\Http\UploadedFile;
|
|||
use Illuminate\Database\ConnectionInterface;
|
||||
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
||||
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\Pack\InvalidFileUploadException;
|
||||
use Pterodactyl\Exceptions\Service\Egg\BadJsonFormatException;
|
||||
use Pterodactyl\Exceptions\Service\InvalidFileUploadException;
|
||||
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
|
||||
|
||||
class EggImporterService
|
||||
|
@ -69,7 +70,8 @@ class EggImporterService
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Pack\InvalidFileUploadException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\BadJsonFormatException
|
||||
* @throws \Pterodactyl\Exceptions\Service\InvalidFileUploadException
|
||||
*/
|
||||
public function handle(UploadedFile $file, int $nest): Egg
|
||||
{
|
||||
|
@ -78,6 +80,11 @@ class EggImporterService
|
|||
}
|
||||
|
||||
$parsed = json_decode($file->openFile()->fread($file->getSize()));
|
||||
if (json_last_error() !== 0) {
|
||||
throw new BadJsonFormatException(trans('exceptions.nest.importer.json_error', [
|
||||
'error' => json_last_error_msg(),
|
||||
]));
|
||||
}
|
||||
|
||||
if (object_get($parsed, 'meta.version') !== 'PTDL_v1') {
|
||||
throw new InvalidFileUploadException(trans('exceptions.nest.importer.invalid_json_provided'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue