|
12 | 12 | use Lcobucci\JWT\Signer\Hmac\Sha256; |
13 | 13 | use Illuminate\Database\ConnectionInterface; |
14 | 14 | use Pterodactyl\Http\Controllers\Controller; |
15 | | -use Pterodactyl\Services\Servers\SuspensionService; |
16 | 15 | use Pterodactyl\Repositories\Eloquent\NodeRepository; |
17 | 16 | use Pterodactyl\Repositories\Eloquent\ServerRepository; |
18 | 17 | use Pterodactyl\Repositories\Wings\DaemonServerRepository; |
@@ -114,9 +113,8 @@ public function archive(Request $request, string $uuid) |
114 | 113 | if (! $request->input('successful')) { |
115 | 114 | $transfer = $server->transfer; |
116 | 115 |
|
117 | | - $transfer->forceFill([ |
118 | | - 'successful' => false, |
119 | | - ])->saveOrFail(); |
| 116 | + $transfer->successful = false; |
| 117 | + $transfer->saveOrFail(); |
120 | 118 |
|
121 | 119 | $allocationIds = json_decode($transfer->new_additional_allocations); |
122 | 120 | array_push($allocationIds, $transfer->new_allocation); |
@@ -189,9 +187,19 @@ public function failure(string $uuid) |
189 | 187 | $allocationIds = json_decode($transfer->new_additional_allocations); |
190 | 188 | array_push($allocationIds, $transfer->new_allocation); |
191 | 189 |
|
| 190 | + // Begin a transaction. |
| 191 | + $this->connection->beginTransaction(); |
| 192 | + |
| 193 | + // Mark the transfer as unsuccessful. |
| 194 | + $transfer->successful = false; |
| 195 | + $transfer->saveOrFail(); |
| 196 | + |
192 | 197 | // Remove the new allocations. |
193 | 198 | $this->allocationRepository->updateWhereIn('id', $allocationIds, ['server_id' => null]); |
194 | 199 |
|
| 200 | + // Commit the transaction. |
| 201 | + $this->connection->commit(); |
| 202 | + |
195 | 203 | return new JsonResponse([], Response::HTTP_NO_CONTENT); |
196 | 204 | } |
197 | 205 |
|
@@ -236,9 +244,6 @@ public function success(string $uuid) |
236 | 244 | $this->writer->warning($exception); |
237 | 245 | } |
238 | 246 |
|
239 | | - // Unsuspend the server |
240 | | - $server->load('node'); |
241 | | - |
242 | 247 | return new JsonResponse([], Response::HTTP_NO_CONTENT); |
243 | 248 | } |
244 | 249 | } |
0 commit comments