summaryrefslogtreecommitdiffstats
path: root/lib/private/Updater.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-06-18 17:23:54 +0200
committerMorris Jobke <hey@morrisjobke.de>2018-06-19 14:22:45 +0200
commit18e9631810ad1d3d72c2b4bbee330169808108ad (patch)
tree866c49dbb113b6c45c5fe618f6b1b4020759646a /lib/private/Updater.php
parent0f84351a762b83322ed556e3d023935720fc6fa4 (diff)
downloadnextcloud-server-18e9631810ad1d3d72c2b4bbee330169808108ad.tar.gz
nextcloud-server-18e9631810ad1d3d72c2b4bbee330169808108ad.zip
Wait for cron to finish before running upgrade command
* fixes #9562 Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/Updater.php')
-rw-r--r--lib/private/Updater.php24
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index e6e38798142..02b3138f30f 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -38,6 +38,7 @@ use OC\DB\MigrationService;
use OC\Hooks\BasicEmitter;
use OC\IntegrityCheck\Checker;
use OC_App;
+use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
use OCP\ILogger;
use OCP\Util;
@@ -66,6 +67,9 @@ class Updater extends BasicEmitter {
/** @var Installer */
private $installer;
+ /** @var IJobList */
+ private $jobList;
+
private $logLevelNames = [
0 => 'Debug',
1 => 'Info',
@@ -74,20 +78,16 @@ class Updater extends BasicEmitter {
4 => 'Fatal',
];
- /**
- * @param IConfig $config
- * @param Checker $checker
- * @param ILogger $log
- * @param Installer $installer
- */
public function __construct(IConfig $config,
Checker $checker,
- ILogger $log = null,
- Installer $installer) {
+ ILogger $log,
+ Installer $installer,
+ IJobList $jobList) {
$this->log = $log;
$this->config = $config;
$this->checker = $checker;
$this->installer = $installer;
+ $this->jobList = $jobList;
}
/**
@@ -111,6 +111,8 @@ class Updater extends BasicEmitter {
$this->emit('\OC\Updater', 'maintenanceEnabled');
}
+ $this->waitForCronToFinish();
+
$installedVersion = $this->config->getSystemValue('version', '0.0.0');
$currentVersion = implode('.', \OCP\Util::getVersion());
$this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
@@ -604,6 +606,12 @@ class Updater extends BasicEmitter {
});
}
+ private function waitForCronToFinish() {
+ while ($this->jobList->isAnyJobRunning()) {
+ $this->emit('\OC\Updater', 'waitForCronToFinish');
+ sleep(5);
+ }
+ }
}