Fix failed transfers locking a server into a unaccessible state
This commit is contained in:
parent
37cfa151b6
commit
d8f75fa0b7
1 changed files with 12 additions and 7 deletions
|
@ -12,7 +12,6 @@ use Illuminate\Http\JsonResponse;
|
||||||
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
||||||
use Illuminate\Database\ConnectionInterface;
|
use Illuminate\Database\ConnectionInterface;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Services\Servers\SuspensionService;
|
|
||||||
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
use Pterodactyl\Repositories\Eloquent\NodeRepository;
|
||||||
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
use Pterodactyl\Repositories\Eloquent\ServerRepository;
|
||||||
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
use Pterodactyl\Repositories\Wings\DaemonServerRepository;
|
||||||
|
@ -114,9 +113,8 @@ class ServerTransferController extends Controller
|
||||||
if (! $request->input('successful')) {
|
if (! $request->input('successful')) {
|
||||||
$transfer = $server->transfer;
|
$transfer = $server->transfer;
|
||||||
|
|
||||||
$transfer->forceFill([
|
$transfer->successful = false;
|
||||||
'successful' => false,
|
$transfer->saveOrFail();
|
||||||
])->saveOrFail();
|
|
||||||
|
|
||||||
$allocationIds = json_decode($transfer->new_additional_allocations);
|
$allocationIds = json_decode($transfer->new_additional_allocations);
|
||||||
array_push($allocationIds, $transfer->new_allocation);
|
array_push($allocationIds, $transfer->new_allocation);
|
||||||
|
@ -189,9 +187,19 @@ class ServerTransferController extends Controller
|
||||||
$allocationIds = json_decode($transfer->new_additional_allocations);
|
$allocationIds = json_decode($transfer->new_additional_allocations);
|
||||||
array_push($allocationIds, $transfer->new_allocation);
|
array_push($allocationIds, $transfer->new_allocation);
|
||||||
|
|
||||||
|
// Begin a transaction.
|
||||||
|
$this->connection->beginTransaction();
|
||||||
|
|
||||||
|
// Mark the transfer as unsuccessful.
|
||||||
|
$transfer->successful = false;
|
||||||
|
$transfer->saveOrFail();
|
||||||
|
|
||||||
// Remove the new allocations.
|
// Remove the new allocations.
|
||||||
$this->allocationRepository->updateWhereIn('id', $allocationIds, ['server_id' => null]);
|
$this->allocationRepository->updateWhereIn('id', $allocationIds, ['server_id' => null]);
|
||||||
|
|
||||||
|
// Commit the transaction.
|
||||||
|
$this->connection->commit();
|
||||||
|
|
||||||
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,9 +244,6 @@ class ServerTransferController extends Controller
|
||||||
$this->writer->warning($exception);
|
$this->writer->warning($exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unsuspend the server
|
|
||||||
$server->load('node');
|
|
||||||
|
|
||||||
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue