Skip to content

Commit 815e1e4

Browse files
authored
Ensure server is not in a conflicting state before initiating a transfer (pterodactyl#4403)
1 parent ff37c51 commit 815e1e4

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

app/Http/Controllers/Admin/Servers/ServerTransferController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public function transfer(Request $request, Server $server)
9797
// Check if the selected daemon is online.
9898
$this->daemonConfigurationRepository->setNode($node)->getSystemInformation();
9999

100+
$server->validateTransferState();
101+
100102
// Create a new ServerTransfer entry.
101103
$transfer = new ServerTransfer();
102104

app/Models/Server.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,4 +400,21 @@ public function validateCurrentState()
400400
throw new ServerStateConflictException($this);
401401
}
402402
}
403+
404+
/**
405+
* Checks if the server is currently in a transferable state. If not, an
406+
* exception is raised. This should be called whenever something needs to make
407+
* sure the server is able to be transferred and is not currently being transferred
408+
* or installed.
409+
*/
410+
public function validateTransferState()
411+
{
412+
if (
413+
!$this->isInstalled() ||
414+
$this->status === self::STATUS_RESTORING_BACKUP ||
415+
!is_null($this->transfer)
416+
) {
417+
throw new ServerStateConflictException($this);
418+
}
419+
}
403420
}

0 commit comments

Comments
 (0)