Skip to content

Commit 3ca7e4d

Browse files
committed
prevent daemon call until confirming DB has been updated
closes pterodactyl#71
1 parent e8c175f commit 3ca7e4d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/Repositories/ServerRepository.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,10 @@ public function changeBuild($id, array $data)
504504
$server->io = $data['io'];
505505
}
506506

507+
// Try save() here so if it fails we haven't contacted the daemon
508+
// This won't be committed unless the HTTP request succeedes anyways
509+
$server->save();
510+
507511
$node = Models\Node::getByID($server->node);
508512
$client = Models\Node::guzzleRequest($server->node);
509513

@@ -527,7 +531,7 @@ public function changeBuild($id, array $data)
527531
]
528532
]
529533
]);
530-
$server->save();
534+
531535
DB::commit();
532536
return true;
533537
} catch (\GuzzleHttp\Exception\TransferException $ex) {

0 commit comments

Comments
 (0)