Skip to content

Commit 8d297a0

Browse files
committed
Release reserved allocations upon archive failure
1 parent 01926e2 commit 8d297a0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/Http/Controllers/Api/Remote/Servers/ServerTransferController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,18 @@ public function archive(Request $request, string $uuid)
112112

113113
// Unsuspend the server and don't continue the transfer.
114114
if (! $request->input('successful')) {
115-
$server->transfer->forceFill([
115+
$transfer = $server->transfer;
116+
117+
$transfer->forceFill([
116118
'successful' => false,
117119
])->saveOrFail();
118120

121+
$allocationIds = json_decode($transfer->new_additional_allocations);
122+
array_push($allocationIds, $transfer->new_allocation);
123+
124+
// Release the reserved allocations.
125+
$this->allocationRepository->updateWhereIn('id', $allocationIds, ['server_id' => null]);
126+
119127
return new JsonResponse([], Response::HTTP_NO_CONTENT);
120128
}
121129

0 commit comments

Comments
 (0)