Release reserved allocations upon archive failure

This commit is contained in:
Matthew Penner 2020-12-16 19:24:39 -07:00
parent 01926e2896
commit 8d297a0918

View file

@ -112,10 +112,18 @@ class ServerTransferController extends Controller
// Unsuspend the server and don't continue the transfer. // Unsuspend the server and don't continue the transfer.
if (! $request->input('successful')) { if (! $request->input('successful')) {
$server->transfer->forceFill([ $transfer = $server->transfer;
$transfer->forceFill([
'successful' => false, 'successful' => false,
])->saveOrFail(); ])->saveOrFail();
$allocationIds = json_decode($transfer->new_additional_allocations);
array_push($allocationIds, $transfer->new_allocation);
// Release the reserved allocations.
$this->allocationRepository->updateWhereIn('id', $allocationIds, ['server_id' => null]);
return new JsonResponse([], Response::HTTP_NO_CONTENT); return new JsonResponse([], Response::HTTP_NO_CONTENT);
} }