update manager fix
This commit is contained in:
parent
6f67af86f6
commit
cfa50168b3
@ -37,16 +37,16 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
/*
|
/*
|
||||||
* Public Properties
|
* Public Properties
|
||||||
*/
|
*/
|
||||||
|
/** @var PluginUpdateManager $pluginUpdateManager */
|
||||||
public $pluginUpdateManager = null;
|
public $pluginUpdateManager = null;
|
||||||
|
/** @var UpdateData $coreUpdateData */
|
||||||
|
public $coreUpdateData = null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
|
/** @var ManiaControl $maniaControl */
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
/**
|
|
||||||
* @var UpdateData $coreUpdateData
|
|
||||||
*/
|
|
||||||
private $coreUpdateData = null;
|
|
||||||
private $currentBuildDate = null;
|
private $currentBuildDate = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,7 +85,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
/**
|
/**
|
||||||
* Perform Hourly Update Check
|
* Perform Hourly Update Check
|
||||||
*
|
*
|
||||||
* @param $time
|
* @param float $time
|
||||||
*/
|
*/
|
||||||
public function hourlyUpdateCheck($time) {
|
public function hourlyUpdateCheck($time) {
|
||||||
$updateCheckEnabled = $this->maniaControl->settingManager->getSetting($this, self::SETTING_ENABLEUPDATECHECK);
|
$updateCheckEnabled = $this->maniaControl->settingManager->getSetting($this, self::SETTING_ENABLEUPDATECHECK);
|
||||||
@ -117,7 +117,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
*
|
*
|
||||||
* @param callable $function
|
* @param callable $function
|
||||||
*/
|
*/
|
||||||
private function checkCoreUpdateAsync($function) {
|
public function checkCoreUpdateAsync($function) {
|
||||||
$updateChannel = $this->getCurrentUpdateChannelSetting();
|
$updateChannel = $this->getCurrentUpdateChannelSetting();
|
||||||
$url = ManiaControl::URL_WEBSERVICE . 'versions?current=1&channel=' . $updateChannel;
|
$url = ManiaControl::URL_WEBSERVICE . 'versions?current=1&channel=' . $updateChannel;
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getCurrentUpdateChannelSetting() {
|
public function getCurrentUpdateChannelSetting() {
|
||||||
$updateChannel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_CHANNEL);
|
$updateChannel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_CHANNEL);
|
||||||
$updateChannel = strtolower($updateChannel);
|
$updateChannel = strtolower($updateChannel);
|
||||||
if (!in_array($updateChannel, array(self::CHANNEL_RELEASE, self::CHANNEL_BETA, self::CHANNEL_NIGHTLY))) {
|
if (!in_array($updateChannel, array(self::CHANNEL_RELEASE, self::CHANNEL_BETA, self::CHANNEL_NIGHTLY))) {
|
||||||
@ -270,7 +270,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function performCoreUpdate(Player $player = null) {
|
public function performCoreUpdate(Player $player = null) {
|
||||||
if (!$this->coreUpdateData) {
|
if (!$this->coreUpdateData) {
|
||||||
$message = 'Update failed: No update Data available!';
|
$message = 'Update failed: No update Data available!';
|
||||||
if ($player) {
|
if ($player) {
|
||||||
@ -361,7 +361,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
* @param string $date
|
* @param string $date
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function setNightlyBuildDate($date) {
|
public function setNightlyBuildDate($date) {
|
||||||
$nightlyBuildDateFile = ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt';
|
$nightlyBuildDateFile = ManiaControlDir . 'core' . DIRECTORY_SEPARATOR . 'nightly_build.txt';
|
||||||
$success = (bool)file_put_contents($nightlyBuildDateFile, $date);
|
$success = (bool)file_put_contents($nightlyBuildDateFile, $date);
|
||||||
$this->currentBuildDate = $date;
|
$this->currentBuildDate = $date;
|
||||||
@ -453,26 +453,18 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
$self = $this;
|
$self = $this;
|
||||||
$this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$self, &$player) {
|
$maniaControl = $this->maniaControl;
|
||||||
|
$this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$self, &$maniaControl, &$player) {
|
||||||
if (!$updateData) {
|
if (!$updateData) {
|
||||||
$self->maniaControl->chat->sendError('Update is currently not possible!', $player->login);
|
$maniaControl->chat->sendError('Update is currently not possible!', $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$self->checkUpdateDataBuildVersion($updateData)) {
|
if (!$self->checkUpdateDataBuildVersion($updateData)) {
|
||||||
$self->maniaControl->chat->sendError("The Next ManiaControl Update requires a newer Dedicated Server Version!", $player->login);
|
$maniaControl->chat->sendError("The Next ManiaControl Update requires a newer Dedicated Server Version!", $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = "Starting Update to Version v{$updateData->version}...";
|
$self->coreUpdateData = $updateData;
|
||||||
$self->maniaControl->chat->sendInformation($message, $player->login);
|
|
||||||
$self->maniaControl->log($message);
|
|
||||||
|
|
||||||
$performBackup = $self->maniaControl->settingManager->getSetting($self, UpdateManager::SETTING_PERFORM_BACKUPS);
|
|
||||||
if ($performBackup && !BackupUtil::performFullBackup()) {
|
|
||||||
$message = 'Creating Backup failed!';
|
|
||||||
$self->maniaControl->chat->sendError($message, $player->login);
|
|
||||||
$self->maniaControl->log($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
$self->performCoreUpdate($player);
|
$self->performCoreUpdate($player);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user