Skip to content

Commit 8d69a60

Browse files
committed
Only allow restoring valid backups, set the server correctly on the repository
1 parent 575eab9 commit 8d69a60

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/Http/Controllers/Api/Client/Servers/BackupController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ public function restore(Request $request, Server $server, Backup $backup)
213213
throw new BadRequestHttpException('This server is not currently in a state that allows for a backup to be restored.');
214214
}
215215

216+
if (!$backup->is_successful && !$backup->completed_at) {
217+
throw new BadRequestHttpException('This backup cannot be restored at this time: not completed or failed.');
218+
}
219+
216220
$server->audit(AuditLog::SERVER__BACKUP_RESTORE_STARTED, function (AuditLog $audit, Server $server) use ($backup, $request) {
217221
$audit->metadata = ['backup_uuid' => $backup->uuid];
218222

@@ -226,7 +230,7 @@ public function restore(Request $request, Server $server, Backup $backup)
226230
// actions against it via the Panel API.
227231
$server->update(['status' => Server::STATUS_RESTORING_BACKUP]);
228232

229-
$this->repository->restore($backup, $url ?? null, $request->input('truncate') === 'true');
233+
$this->repository->setServer($server)->restore($backup, $url ?? null, $request->input('truncate') === 'true');
230234
});
231235

232236
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);

0 commit comments

Comments
 (0)