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