Replace calls to server patch with a manual sync method
This commit is contained in:
parent
d8d1eacb42
commit
2d47f986ee
3 changed files with 8 additions and 29 deletions
|
@ -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.
|
||||
|
|
Reference in a new issue