Don't require Wings API call to pass in order to update server details

This commit is contained in:
Dane Everitt 2021-08-29 13:19:24 -07:00
parent 7330a747b7
commit d8d1eacb42
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -33,6 +33,8 @@ class BuildModificationService
* BuildModificationService constructor.
*
* @param \Pterodactyl\Services\Servers\ServerConfigurationStructureService $structureService
* @param \Illuminate\Database\ConnectionInterface $connection
* @param \Pterodactyl\Repositories\Wings\DaemonServerRepository $daemonServerRepository
*/
public function __construct(
ServerConfigurationStructureService $structureService,
@ -56,6 +58,8 @@ class BuildModificationService
{
$this->connection->beginTransaction();
/** @var \Pterodactyl\Models\Server $server */
$server = $this->connection->transaction(function() use ($server, $data) {
$this->processAllocations($server, $data);
if (isset($data['allocation_id']) && $data['allocation_id'] != $server->allocation_id) {
@ -76,14 +80,15 @@ class BuildModificationService
'backup_limit' => Arr::get($data, 'backup_limit', 0) ?? 0,
]))->saveOrFail();
$server = $server->fresh();
return $server->refresh();
});
$updateData = $this->structureService->handle($server);
// Because Wings always fetches an updated configuration from the Panel when booting
// a server this type of exception can be safely "ignored" and just written to the logs.
// Ideally this request succeedes so we can apply resource modifications on the fly
// but if it fails it isn't the end of the world.
// Ideally this request succeedes so we can apply resource modifications on the fly, but
// if it fails we can just continue on as normal.
if (!empty($updateData['build'])) {
try {
$this->daemonServerRepository->setServer($server)->update([
@ -94,8 +99,6 @@ class BuildModificationService
}
}
$this->connection->commit();
return $server;
}