Ensure server is not in a conflicting state before initiating a transfer (#4403)
This commit is contained in:
parent
ff37c51eef
commit
815e1e4c4d
2 changed files with 19 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue