Replace calls to server patch with a manual sync method
This commit is contained in:
parent
d8d1eacb42
commit
2d47f986ee
|
@ -4,6 +4,7 @@ namespace Pterodactyl\Repositories\Wings;
|
|||
|
||||
use Webmozart\Assert\Assert;
|
||||
use Pterodactyl\Models\Server;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Exception\TransferException;
|
||||
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
|
||||
|
||||
|
@ -51,17 +52,17 @@ class DaemonServerRepository extends DaemonRepository
|
|||
}
|
||||
|
||||
/**
|
||||
* Updates details about a server on the Daemon.
|
||||
* Triggers a server sync on Wings.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function update(array $data): void
|
||||
public function sync(): void
|
||||
{
|
||||
Assert::isInstanceOf($this->server, Server::class);
|
||||
|
||||
try {
|
||||
$this->getHttpClient()->patch('/api/servers/' . $this->server->uuid, ['json' => $data]);
|
||||
} catch (TransferException $exception) {
|
||||
$this->getHttpClient()->post("/api/servers/{$this->server->uuid}/sync");
|
||||
} catch (GuzzleException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
}
|
||||
|
@ -101,26 +102,6 @@ class DaemonServerRepository extends DaemonRepository
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* By default this function will suspend a server instance on the daemon. However, passing
|
||||
* "true" as the first argument will unsuspend the server.
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function suspend(bool $unsuspend = false): void
|
||||
{
|
||||
Assert::isInstanceOf($this->server, Server::class);
|
||||
|
||||
try {
|
||||
$this->getHttpClient()->patch(
|
||||
'/api/servers/' . $this->server->uuid,
|
||||
['json' => ['suspended' => !$unsuspend]]
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests the daemon to create a full archive of the server. Once the daemon is finished
|
||||
* they will send a POST request to "/api/remote/servers/{uuid}/archive" with a boolean.
|
||||
|
|
|
@ -91,9 +91,7 @@ class BuildModificationService
|
|||
// if it fails we can just continue on as normal.
|
||||
if (!empty($updateData['build'])) {
|
||||
try {
|
||||
$this->daemonServerRepository->setServer($server)->update([
|
||||
'build' => $updateData['build'],
|
||||
]);
|
||||
$this->daemonServerRepository->setServer($server)->sync();
|
||||
} catch (DaemonConnectionException $exception) {
|
||||
Log::warning($exception, ['server_id' => $server->id]);
|
||||
}
|
||||
|
|
|
@ -63,9 +63,9 @@ class SuspensionService
|
|||
'status' => $isSuspending ? Server::STATUS_SUSPENDED : null,
|
||||
]);
|
||||
|
||||
// Only send the suspension request to wings if the server is not currently being transferred.
|
||||
// Only trigger a Wings server sync if it is not currently being transferred.
|
||||
if (is_null($server->transfer)) {
|
||||
$this->daemonServerRepository->setServer($server)->suspend($action === self::ACTION_UNSUSPEND);
|
||||
$this->daemonServerRepository->setServer($server)->sync();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue