Merge pull request #16434 from owncloud/persist-maintenance-state
Persist the state of the maintenance after an upgrade
This commit is contained in:
commit
739c3f01aa
|
@ -44,12 +44,15 @@ if (OC::checkUpgrade(false)) {
|
||||||
$incompatibleApps = [];
|
$incompatibleApps = [];
|
||||||
$disabledThirdPartyApps = [];
|
$disabledThirdPartyApps = [];
|
||||||
|
|
||||||
$updater->listen('\OC\Updater', 'maintenanceStart', function () use ($eventSource, $l) {
|
$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) {
|
||||||
$eventSource->send('success', (string)$l->t('Turned on maintenance mode'));
|
$eventSource->send('success', (string)$l->t('Turned on maintenance mode'));
|
||||||
});
|
});
|
||||||
$updater->listen('\OC\Updater', 'maintenanceEnd', function () use ($eventSource, $l) {
|
$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use ($eventSource, $l) {
|
||||||
$eventSource->send('success', (string)$l->t('Turned off maintenance mode'));
|
$eventSource->send('success', (string)$l->t('Turned off maintenance mode'));
|
||||||
});
|
});
|
||||||
|
$updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) {
|
||||||
|
$eventSource->send('success', (string)$l->t('Maintenance mode is kept active'));
|
||||||
|
});
|
||||||
$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) {
|
$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) {
|
||||||
$eventSource->send('success', (string)$l->t('Updated database'));
|
$eventSource->send('success', (string)$l->t('Updated database'));
|
||||||
});
|
});
|
||||||
|
|
|
@ -118,12 +118,17 @@ class Upgrade extends Command {
|
||||||
$updater->setUpdateStepEnabled($updateStepEnabled);
|
$updater->setUpdateStepEnabled($updateStepEnabled);
|
||||||
$updater->setSkip3rdPartyAppsDisable($skip3rdPartyAppsDisable);
|
$updater->setSkip3rdPartyAppsDisable($skip3rdPartyAppsDisable);
|
||||||
|
|
||||||
$updater->listen('\OC\Updater', 'maintenanceStart', function () use($output) {
|
$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) {
|
||||||
$output->writeln('<info>Turned on maintenance mode</info>');
|
$output->writeln('<info>Turned on maintenance mode</info>');
|
||||||
});
|
});
|
||||||
$updater->listen('\OC\Updater', 'maintenanceEnd',
|
$updater->listen('\OC\Updater', 'maintenanceDisabled', function () use($output) {
|
||||||
function () use($output, $updateStepEnabled, $self) {
|
|
||||||
$output->writeln('<info>Turned off maintenance mode</info>');
|
$output->writeln('<info>Turned off maintenance mode</info>');
|
||||||
|
});
|
||||||
|
$updater->listen('\OC\Updater', 'maintenanceActive', function () use($output) {
|
||||||
|
$output->writeln('<info>Maintenance mode is kept active</info>');
|
||||||
|
});
|
||||||
|
$updater->listen('\OC\Updater', 'updateEnd',
|
||||||
|
function () use($output, $updateStepEnabled, $self) {
|
||||||
$mode = $updateStepEnabled ? 'Update' : 'Update simulation';
|
$mode = $updateStepEnabled ? 'Update' : 'Update simulation';
|
||||||
$status = $self->upgradeFailed ? 'failed' : 'successful';
|
$status = $self->upgradeFailed ? 'failed' : 'successful';
|
||||||
$message = "<info>$mode $status</info>";
|
$message = "<info>$mode $status</info>";
|
||||||
|
|
|
@ -176,14 +176,18 @@ class Updater extends BasicEmitter {
|
||||||
* @return bool true if the operation succeeded, false otherwise
|
* @return bool true if the operation succeeded, false otherwise
|
||||||
*/
|
*/
|
||||||
public function upgrade() {
|
public function upgrade() {
|
||||||
|
$wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false);
|
||||||
|
|
||||||
|
if(!$wasMaintenanceModeEnabled) {
|
||||||
$this->config->setSystemValue('maintenance', true);
|
$this->config->setSystemValue('maintenance', true);
|
||||||
|
$this->emit('\OC\Updater', 'maintenanceEnabled');
|
||||||
|
}
|
||||||
|
|
||||||
$installedVersion = $this->config->getSystemValue('version', '0.0.0');
|
$installedVersion = $this->config->getSystemValue('version', '0.0.0');
|
||||||
$currentVersion = implode('.', \OC_Util::getVersion());
|
$currentVersion = implode('.', \OC_Util::getVersion());
|
||||||
if ($this->log) {
|
if ($this->log) {
|
||||||
$this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
|
$this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
|
||||||
}
|
}
|
||||||
$this->emit('\OC\Updater', 'maintenanceStart');
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->doUpgrade($currentVersion, $installedVersion);
|
$this->doUpgrade($currentVersion, $installedVersion);
|
||||||
|
@ -191,8 +195,14 @@ class Updater extends BasicEmitter {
|
||||||
$this->emit('\OC\Updater', 'failure', array($exception->getMessage()));
|
$this->emit('\OC\Updater', 'failure', array($exception->getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->emit('\OC\Updater', 'updateEnd');
|
||||||
|
|
||||||
|
if(!$wasMaintenanceModeEnabled) {
|
||||||
$this->config->setSystemValue('maintenance', false);
|
$this->config->setSystemValue('maintenance', false);
|
||||||
$this->emit('\OC\Updater', 'maintenanceEnd');
|
$this->emit('\OC\Updater', 'maintenanceDisabled');
|
||||||
|
} else {
|
||||||
|
$this->emit('\OC\Updater', 'maintenanceActive');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue