From 9200bbeabad801d54f69a1fedf23292afda27521 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 21 Oct 2015 09:17:38 +0200 Subject: [PATCH] Update: state which step we are going to start and warn if it might be slow --- core/ajax/update.php | 12 ++++++++++++ core/command/upgrade.php | 12 ++++++++++++ lib/private/updater.php | 6 ++++++ 3 files changed, 30 insertions(+) diff --git a/core/ajax/update.php b/core/ajax/update.php index 11d159f15d..dfec64cd2c 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -68,12 +68,24 @@ if (OC::checkUpgrade(false)) { $updater->listen('\OC\Updater', 'maintenanceActive', function () use ($eventSource, $l) { $eventSource->send('success', (string)$l->t('Maintenance mode is kept active')); }); + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($eventSource, $l) { + $eventSource->send('success', (string)$l->t('Updating database schema')); + }); $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($eventSource, $l) { $eventSource->send('success', (string)$l->t('Updated database')); }); + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($eventSource, $l) { + $eventSource->send('success', (string)$l->t('Checking whether the database schema can be updated (this can take a long time depending on the database size)')); + }); $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use ($eventSource, $l) { $eventSource->send('success', (string)$l->t('Checked database schema update')); }); + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($eventSource, $l) { + $eventSource->send('success', (string)$l->t('Checking updates of apps')); + }); + $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($eventSource, $l) { + $eventSource->send('success', (string)$l->t('Checking whether the database schema for %s can be updated (this can take a long time depending on the database size)', [$app])); + }); $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($eventSource, $l) { $eventSource->send('success', (string)$l->t('Checked database schema update for apps')); }); diff --git a/core/command/upgrade.php b/core/command/upgrade.php index 5d4819f6ba..9c313f83e1 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -155,9 +155,15 @@ class Upgrade extends Command { } $output->writeln($message); }); + $updater->listen('\OC\Updater', 'dbUpgradeBefore', function () use($output) { + $output->writeln('Updating database schema'); + }); $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { $output->writeln('Updated database'); }); + $updater->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($output) { + $output->writeln('Checking whether the database schema can be updated (this can take a long time depending on the database size)'); + }); $updater->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($output) { $output->writeln('Checked database schema update'); }); @@ -176,6 +182,12 @@ class Upgrade extends Command { $updater->listen('\OC\Updater', 'repairError', function ($app) use($output) { $output->writeln('Repair error: ' . $app . ''); }); + $updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) { + $output->writeln('Checking updates of apps'); + }); + $updater->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($output) { + $output->writeln("Checking whether the database schema for <$app> can be updated (this can take a long time depending on the database size)"); + }); $updater->listen('\OC\Updater', 'appUpgradeCheck', function () use ($output) { $output->writeln('Checked database schema update for apps'); }); diff --git a/lib/private/updater.php b/lib/private/updater.php index 70d6886378..9e5207c2a1 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -337,6 +337,8 @@ class Updater extends BasicEmitter { } protected function checkCoreUpgrade() { + $this->emit('\OC\Updater', 'dbSimulateUpgradeBefore'); + // simulate core DB upgrade \OC_DB::simulateUpdateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml'); @@ -344,6 +346,8 @@ class Updater extends BasicEmitter { } protected function doCoreUpgrade() { + $this->emit('\OC\Updater', 'dbUpgradeBefore'); + // do the real upgrade \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml'); @@ -355,6 +359,7 @@ class Updater extends BasicEmitter { */ protected function checkAppUpgrade($version) { $apps = \OC_App::getEnabledApps(); + $this->emit('\OC\Updater', 'appUpgradeCheckBefore'); foreach ($apps as $appId) { $info = \OC_App::getAppInfo($appId); @@ -372,6 +377,7 @@ class Updater extends BasicEmitter { $this->includePreUpdate($appId); } if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) { + $this->emit('\OC\Updater', 'appSimulateUpdate', array($appId)); \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml'); } }