Remove unnecessary calls to Wings to add/remove mounts

This commit is contained in:
Dane Everitt 2020-11-02 19:58:14 -08:00
parent ebd81e9d1d
commit b482632af4
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -420,27 +420,19 @@ class ServersController extends Controller
*
* @param Server $server
* @param \Pterodactyl\Models\Mount $mount
*
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException|\Throwable
*
* @throws \Throwable
*/
public function addMount(Server $server, Mount $mount)
{
$mountServer = new MountServer;
$mountServer->mount_id = $mount->id;
$mountServer->server_id = $server->id;
$mountServer = (new MountServer)->forceFill([
'mount_id' => $mount->id,
'server_id' => $server->id,
]);
$mountServer->saveOrFail();
$data = $this->serverConfigurationStructureService->handle($server);
try {
$this->daemonServerRepository
->setServer($server)
->update(Arr::only($data, ['mounts']));
} catch (RequestException $exception) {
throw new DaemonConnectionException($exception);
}
$this->alert->success('Mount was added successfully.')->flash();
return redirect()->route('admin.servers.view.mounts', $server->id);
@ -452,24 +444,11 @@ class ServersController extends Controller
* @param Server $server
* @param \Pterodactyl\Models\Mount $mount
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function deleteMount(Server $server, Mount $mount)
{
MountServer::where('mount_id', $mount->id)->where('server_id', $server->id)->delete();
$data = $this->serverConfigurationStructureService->handle($server);
try {
$this->daemonServerRepository
->setServer($server)
->update(Arr::only($data, ['mounts']));
} catch (RequestException $exception) {
throw new DaemonConnectionException($exception);
}
$this->alert->success('Mount was removed successfully.')->flash();
return redirect()->route('admin.servers.view.mounts', $server->id);