Pass the updated model through for updating node config, rather than old model, ref #1237

This commit is contained in:
Dane Everitt 2018-09-03 14:54:50 -07:00
parent 7ed9c7cb93
commit 3bb9bf04e5
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 5 additions and 11 deletions

View file

@ -7,6 +7,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
### Fixed
* Scheduled tasks triggered manually no longer improperly change the `next_run_at` time and do not run twice in a row anymore.
* Changing the maximum web-based file upload size for a node now properly validates and updates.
* Changing configuration values for a node now correctly updates them on the daemon on the first request, rather than requiring a second request to set them.
### Changed
* Egg and server variable values are no longer limited to 191 characters. Turns out some games require a large number of characters in these fields.

View file

@ -124,7 +124,7 @@ class NodeController extends ApplicationApiController
*/
public function update(UpdateNodeRequest $request): array
{
$node = $this->updateService->returnUpdatedModel()->handle(
$node = $this->updateService->handle(
$request->getModel(Node::class), $request->validated()
);

View file

@ -13,7 +13,6 @@ use Pterodactyl\Models\Node;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Traits\Services\ReturnsUpdatedModels;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
use Pterodactyl\Exceptions\Service\Node\ConfigurationNotPersistedException;
@ -21,8 +20,6 @@ use Pterodactyl\Contracts\Repository\Daemon\ConfigurationRepositoryInterface;
class NodeUpdateService
{
use ReturnsUpdatedModels;
/**
* @var \Illuminate\Database\ConnectionInterface
*/
@ -74,14 +71,10 @@ class NodeUpdateService
}
$this->connection->beginTransaction();
if ($this->getUpdatedModel()) {
$response = $this->repository->update($node->id, $data);
} else {
$response = $this->repository->withoutFreshModel()->update($node->id, $data);
}
$updatedModel = $this->repository->update($node->id, $data);
try {
$this->configRepository->setNode($node)->update();
$this->configRepository->setNode($updatedModel)->update();
$this->connection->commit();
} catch (RequestException $exception) {
// Failed to connect to the Daemon. Let's go ahead and save the configuration
@ -95,6 +88,6 @@ class NodeUpdateService
throw new DaemonConnectionException($exception);
}
return $response;
return $updatedModel;
}
}