1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 09:02:28 +01:00

Ensure server is not in a conflicting state before initiating a transfer (#4403)

This commit is contained in:
Matthew Penner 2022-10-04 19:57:24 -06:00 committed by GitHub
parent ff37c51eef
commit 815e1e4c4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -97,6 +97,8 @@ class ServerTransferController extends Controller
// Check if the selected daemon is online.
$this->daemonConfigurationRepository->setNode($node)->getSystemInformation();
$server->validateTransferState();
// Create a new ServerTransfer entry.
$transfer = new ServerTransfer();

View File

@ -400,4 +400,21 @@ class Server extends Model
throw new ServerStateConflictException($this);
}
}
/**
* Checks if the server is currently in a transferable state. If not, an
* exception is raised. This should be called whenever something needs to make
* sure the server is able to be transferred and is not currently being transferred
* or installed.
*/
public function validateTransferState()
{
if (
!$this->isInstalled() ||
$this->status === self::STATUS_RESTORING_BACKUP ||
!is_null($this->transfer)
) {
throw new ServerStateConflictException($this);
}
}
}