Updater.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch>
  6. *
  7. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  8. * @author Bjoern Schiessle <bjoern@schiessle.org>
  9. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  10. * @author Frank Karlitschek <frank@karlitschek.de>
  11. * @author Georg Ehrke <oc.list@georgehrke.com>
  12. * @author J0WI <J0WI@users.noreply.github.com>
  13. * @author Joas Schilling <coding@schilljs.com>
  14. * @author Julius Härtl <jus@bitgrid.net>
  15. * @author Lukas Reschke <lukas@statuscode.ch>
  16. * @author Morris Jobke <hey@morrisjobke.de>
  17. * @author Robin Appelman <robin@icewind.nl>
  18. * @author Roeland Jago Douma <roeland@famdouma.nl>
  19. * @author Steffen Lindner <mail@steffen-lindner.de>
  20. * @author Thomas Müller <thomas.mueller@tmit.eu>
  21. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  22. * @author Vincent Petry <vincent@nextcloud.com>
  23. *
  24. * @license AGPL-3.0
  25. *
  26. * This code is free software: you can redistribute it and/or modify
  27. * it under the terms of the GNU Affero General Public License, version 3,
  28. * as published by the Free Software Foundation.
  29. *
  30. * This program is distributed in the hope that it will be useful,
  31. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. * GNU Affero General Public License for more details.
  34. *
  35. * You should have received a copy of the GNU Affero General Public License, version 3,
  36. * along with this program. If not, see <http://www.gnu.org/licenses/>
  37. *
  38. */
  39. namespace OC;
  40. use OCP\App\IAppManager;
  41. use OCP\EventDispatcher\Event;
  42. use OCP\EventDispatcher\IEventDispatcher;
  43. use OCP\HintException;
  44. use OCP\IConfig;
  45. use OCP\ILogger;
  46. use OCP\Util;
  47. use OC\App\AppManager;
  48. use OC\DB\Connection;
  49. use OC\DB\MigrationService;
  50. use OC\DB\MigratorExecuteSqlEvent;
  51. use OC\Hooks\BasicEmitter;
  52. use OC\IntegrityCheck\Checker;
  53. use OC\Repair\Events\RepairAdvanceEvent;
  54. use OC\Repair\Events\RepairErrorEvent;
  55. use OC\Repair\Events\RepairFinishEvent;
  56. use OC\Repair\Events\RepairInfoEvent;
  57. use OC\Repair\Events\RepairStartEvent;
  58. use OC\Repair\Events\RepairStepEvent;
  59. use OC\Repair\Events\RepairWarningEvent;
  60. use OC_App;
  61. use Psr\Log\LoggerInterface;
  62. /**
  63. * Class that handles autoupdating of ownCloud
  64. *
  65. * Hooks provided in scope \OC\Updater
  66. * - maintenanceStart()
  67. * - maintenanceEnd()
  68. * - dbUpgrade()
  69. * - failure(string $message)
  70. */
  71. class Updater extends BasicEmitter {
  72. /** @var LoggerInterface */
  73. private $log;
  74. /** @var IConfig */
  75. private $config;
  76. /** @var Checker */
  77. private $checker;
  78. /** @var Installer */
  79. private $installer;
  80. private $logLevelNames = [
  81. 0 => 'Debug',
  82. 1 => 'Info',
  83. 2 => 'Warning',
  84. 3 => 'Error',
  85. 4 => 'Fatal',
  86. ];
  87. public function __construct(IConfig $config,
  88. Checker $checker,
  89. ?LoggerInterface $log,
  90. Installer $installer) {
  91. $this->log = $log;
  92. $this->config = $config;
  93. $this->checker = $checker;
  94. $this->installer = $installer;
  95. }
  96. /**
  97. * runs the update actions in maintenance mode, does not upgrade the source files
  98. * except the main .htaccess file
  99. *
  100. * @return bool true if the operation succeeded, false otherwise
  101. */
  102. public function upgrade(): bool {
  103. $this->logAllEvents();
  104. $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN);
  105. $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  106. $this->config->setSystemValue('loglevel', ILogger::DEBUG);
  107. $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
  108. if (!$wasMaintenanceModeEnabled) {
  109. $this->config->setSystemValue('maintenance', true);
  110. $this->emit('\OC\Updater', 'maintenanceEnabled');
  111. }
  112. // Clear CAN_INSTALL file if not on git
  113. if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
  114. if (!unlink(\OC::$configDir . '/CAN_INSTALL')) {
  115. $this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.');
  116. }
  117. }
  118. $installedVersion = $this->config->getSystemValueString('version', '0.0.0');
  119. $currentVersion = implode('.', \OCP\Util::getVersion());
  120. $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, ['app' => 'core']);
  121. $success = true;
  122. try {
  123. $this->doUpgrade($currentVersion, $installedVersion);
  124. } catch (HintException $exception) {
  125. $this->log->error($exception->getMessage(), [
  126. 'exception' => $exception,
  127. ]);
  128. $this->emit('\OC\Updater', 'failure', [$exception->getMessage() . ': ' .$exception->getHint()]);
  129. $success = false;
  130. } catch (\Exception $exception) {
  131. $this->log->error($exception->getMessage(), [
  132. 'exception' => $exception,
  133. ]);
  134. $this->emit('\OC\Updater', 'failure', [get_class($exception) . ': ' .$exception->getMessage()]);
  135. $success = false;
  136. }
  137. $this->emit('\OC\Updater', 'updateEnd', [$success]);
  138. if (!$wasMaintenanceModeEnabled && $success) {
  139. $this->config->setSystemValue('maintenance', false);
  140. $this->emit('\OC\Updater', 'maintenanceDisabled');
  141. } else {
  142. $this->emit('\OC\Updater', 'maintenanceActive');
  143. }
  144. $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  145. $this->config->setSystemValue('loglevel', $logLevel);
  146. $this->config->setSystemValue('installed', true);
  147. return $success;
  148. }
  149. /**
  150. * Return version from which this version is allowed to upgrade from
  151. *
  152. * @return array allowed previous versions per vendor
  153. */
  154. private function getAllowedPreviousVersions(): array {
  155. // this should really be a JSON file
  156. require \OC::$SERVERROOT . '/version.php';
  157. /** @var array $OC_VersionCanBeUpgradedFrom */
  158. return $OC_VersionCanBeUpgradedFrom;
  159. }
  160. /**
  161. * Return vendor from which this version was published
  162. *
  163. * @return string Get the vendor
  164. */
  165. private function getVendor(): string {
  166. // this should really be a JSON file
  167. require \OC::$SERVERROOT . '/version.php';
  168. /** @var string $vendor */
  169. return (string) $vendor;
  170. }
  171. /**
  172. * Whether an upgrade to a specified version is possible
  173. * @param string $oldVersion
  174. * @param string $newVersion
  175. * @param array $allowedPreviousVersions
  176. * @return bool
  177. */
  178. public function isUpgradePossible(string $oldVersion, string $newVersion, array $allowedPreviousVersions): bool {
  179. $version = explode('.', $oldVersion);
  180. $majorMinor = $version[0] . '.' . $version[1];
  181. $currentVendor = $this->config->getAppValue('core', 'vendor', '');
  182. // Vendor was not set correctly on install, so we have to white-list known versions
  183. if ($currentVendor === '' && (
  184. isset($allowedPreviousVersions['owncloud'][$oldVersion]) ||
  185. isset($allowedPreviousVersions['owncloud'][$majorMinor])
  186. )) {
  187. $currentVendor = 'owncloud';
  188. $this->config->setAppValue('core', 'vendor', $currentVendor);
  189. }
  190. if ($currentVendor === 'nextcloud') {
  191. return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
  192. && (version_compare($oldVersion, $newVersion, '<=') ||
  193. $this->config->getSystemValueBool('debug', false));
  194. }
  195. // Check if the instance can be migrated
  196. return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) ||
  197. isset($allowedPreviousVersions[$currentVendor][$oldVersion]);
  198. }
  199. /**
  200. * runs the update actions in maintenance mode, does not upgrade the source files
  201. * except the main .htaccess file
  202. *
  203. * @param string $currentVersion current version to upgrade to
  204. * @param string $installedVersion previous version from which to upgrade from
  205. *
  206. * @throws \Exception
  207. */
  208. private function doUpgrade(string $currentVersion, string $installedVersion): void {
  209. // Stop update if the update is over several major versions
  210. $allowedPreviousVersions = $this->getAllowedPreviousVersions();
  211. if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
  212. throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
  213. }
  214. // Update .htaccess files
  215. try {
  216. Setup::updateHtaccess();
  217. Setup::protectDataDirectory();
  218. } catch (\Exception $e) {
  219. throw new \Exception($e->getMessage());
  220. }
  221. // create empty file in data dir, so we can later find
  222. // out that this is indeed an ownCloud data directory
  223. // (in case it didn't exist before)
  224. file_put_contents($this->config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
  225. // pre-upgrade repairs
  226. $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->get(LoggerInterface::class));
  227. $repair->run();
  228. $this->doCoreUpgrade();
  229. try {
  230. // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
  231. Setup::installBackgroundJobs();
  232. } catch (\Exception $e) {
  233. throw new \Exception($e->getMessage());
  234. }
  235. // update all shipped apps
  236. $this->checkAppsRequirements();
  237. $this->doAppUpgrade();
  238. // Update the appfetchers version so it downloads the correct list from the appstore
  239. \OC::$server->getAppFetcher()->setVersion($currentVersion);
  240. /** @var AppManager $appManager */
  241. $appManager = \OC::$server->getAppManager();
  242. // upgrade appstore apps
  243. $this->upgradeAppStoreApps($appManager->getInstalledApps());
  244. $autoDisabledApps = $appManager->getAutoDisabledApps();
  245. if (!empty($autoDisabledApps)) {
  246. $this->upgradeAppStoreApps(array_keys($autoDisabledApps), $autoDisabledApps);
  247. }
  248. // install new shipped apps on upgrade
  249. $errors = Installer::installShippedApps(true);
  250. foreach ($errors as $appId => $exception) {
  251. /** @var \Exception $exception */
  252. $this->log->error($exception->getMessage(), [
  253. 'exception' => $exception,
  254. 'app' => $appId,
  255. ]);
  256. $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
  257. }
  258. // post-upgrade repairs
  259. $repair = new Repair(Repair::getRepairSteps(), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->get(LoggerInterface::class));
  260. $repair->run();
  261. //Invalidate update feed
  262. $this->config->setAppValue('core', 'lastupdatedat', '0');
  263. // Check for code integrity if not disabled
  264. if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
  265. $this->emit('\OC\Updater', 'startCheckCodeIntegrity');
  266. $this->checker->runInstanceVerification();
  267. $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity');
  268. }
  269. // only set the final version if everything went well
  270. $this->config->setSystemValue('version', implode('.', Util::getVersion()));
  271. $this->config->setAppValue('core', 'vendor', $this->getVendor());
  272. }
  273. protected function doCoreUpgrade(): void {
  274. $this->emit('\OC\Updater', 'dbUpgradeBefore');
  275. // execute core migrations
  276. $ms = new MigrationService('core', \OC::$server->get(Connection::class));
  277. $ms->migrate();
  278. $this->emit('\OC\Updater', 'dbUpgrade');
  279. }
  280. /**
  281. * upgrades all apps within a major ownCloud upgrade. Also loads "priority"
  282. * (types authentication, filesystem, logging, in that order) afterwards.
  283. *
  284. * @throws NeedsUpdateException
  285. */
  286. protected function doAppUpgrade(): void {
  287. $apps = \OC_App::getEnabledApps();
  288. $priorityTypes = ['authentication', 'extended_authentication', 'filesystem', 'logging'];
  289. $pseudoOtherType = 'other';
  290. $stacks = [$pseudoOtherType => []];
  291. foreach ($apps as $appId) {
  292. $priorityType = false;
  293. foreach ($priorityTypes as $type) {
  294. if (!isset($stacks[$type])) {
  295. $stacks[$type] = [];
  296. }
  297. if (\OC_App::isType($appId, [$type])) {
  298. $stacks[$type][] = $appId;
  299. $priorityType = true;
  300. break;
  301. }
  302. }
  303. if (!$priorityType) {
  304. $stacks[$pseudoOtherType][] = $appId;
  305. }
  306. }
  307. foreach (array_merge($priorityTypes, [$pseudoOtherType]) as $type) {
  308. $stack = $stacks[$type];
  309. foreach ($stack as $appId) {
  310. if (\OC_App::shouldUpgrade($appId)) {
  311. $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OCP\Server::get(IAppManager::class)->getAppVersion($appId)]);
  312. \OC_App::updateApp($appId);
  313. $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OCP\Server::get(IAppManager::class)->getAppVersion($appId)]);
  314. }
  315. if ($type !== $pseudoOtherType) {
  316. // load authentication, filesystem and logging apps after
  317. // upgrading them. Other apps my need to rely on modifying
  318. // user and/or filesystem aspects.
  319. \OC_App::loadApp($appId);
  320. }
  321. }
  322. }
  323. }
  324. /**
  325. * check if the current enabled apps are compatible with the current
  326. * ownCloud version. disable them if not.
  327. * This is important if you upgrade ownCloud and have non ported 3rd
  328. * party apps installed.
  329. *
  330. * @throws \Exception
  331. */
  332. private function checkAppsRequirements(): void {
  333. $isCoreUpgrade = $this->isCodeUpgrade();
  334. $apps = OC_App::getEnabledApps();
  335. $version = implode('.', Util::getVersion());
  336. $appManager = \OC::$server->getAppManager();
  337. foreach ($apps as $app) {
  338. // check if the app is compatible with this version of Nextcloud
  339. $info = $appManager->getAppInfo($app);
  340. if ($info === null || !OC_App::isAppCompatible($version, $info)) {
  341. if ($appManager->isShipped($app)) {
  342. throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
  343. }
  344. $appManager->disableApp($app, true);
  345. $this->emit('\OC\Updater', 'incompatibleAppDisabled', [$app]);
  346. }
  347. }
  348. }
  349. /**
  350. * @return bool
  351. */
  352. private function isCodeUpgrade(): bool {
  353. $installedVersion = $this->config->getSystemValueString('version', '0.0.0');
  354. $currentVersion = implode('.', Util::getVersion());
  355. if (version_compare($currentVersion, $installedVersion, '>')) {
  356. return true;
  357. }
  358. return false;
  359. }
  360. /**
  361. * @param array $apps
  362. * @param array $previousEnableStates
  363. * @throws \Exception
  364. */
  365. private function upgradeAppStoreApps(array $apps, array $previousEnableStates = []): void {
  366. foreach ($apps as $app) {
  367. try {
  368. $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
  369. if ($this->installer->isUpdateAvailable($app)) {
  370. $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]);
  371. $this->installer->updateAppstoreApp($app);
  372. }
  373. $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
  374. if (!empty($previousEnableStates)) {
  375. $ocApp = new \OC_App();
  376. if (!empty($previousEnableStates[$app]) && is_array($previousEnableStates[$app])) {
  377. $ocApp->enable($app, $previousEnableStates[$app]);
  378. } else {
  379. $ocApp->enable($app);
  380. }
  381. }
  382. } catch (\Exception $ex) {
  383. $this->log->error($ex->getMessage(), [
  384. 'exception' => $ex,
  385. ]);
  386. }
  387. }
  388. }
  389. private function logAllEvents(): void {
  390. $log = $this->log;
  391. /** @var IEventDispatcher $dispatcher */
  392. $dispatcher = \OC::$server->get(IEventDispatcher::class);
  393. $dispatcher->addListener(
  394. MigratorExecuteSqlEvent::class,
  395. function (MigratorExecuteSqlEvent $event) use ($log): void {
  396. $log->info(get_class($event).': ' . $event->getSql() . ' (' . $event->getCurrentStep() . ' of ' . $event->getMaxStep() . ')', ['app' => 'updater']);
  397. }
  398. );
  399. $repairListener = function (Event $event) use ($log): void {
  400. if ($event instanceof RepairStartEvent) {
  401. $log->info(get_class($event).': Starting ... ' . $event->getMaxStep() . ' (' . $event->getCurrentStepName() . ')', ['app' => 'updater']);
  402. } elseif ($event instanceof RepairAdvanceEvent) {
  403. $desc = $event->getDescription();
  404. if (empty($desc)) {
  405. $desc = '';
  406. }
  407. $log->info(get_class($event).': ' . $desc . ' (' . $event->getIncrement() . ')', ['app' => 'updater']);
  408. } elseif ($event instanceof RepairFinishEvent) {
  409. $log->info(get_class($event), ['app' => 'updater']);
  410. } elseif ($event instanceof RepairStepEvent) {
  411. $log->info(get_class($event).': Repair step: ' . $event->getStepName(), ['app' => 'updater']);
  412. } elseif ($event instanceof RepairInfoEvent) {
  413. $log->info(get_class($event).': Repair info: ' . $event->getMessage(), ['app' => 'updater']);
  414. } elseif ($event instanceof RepairWarningEvent) {
  415. $log->warning(get_class($event).': Repair warning: ' . $event->getMessage(), ['app' => 'updater']);
  416. } elseif ($event instanceof RepairErrorEvent) {
  417. $log->error(get_class($event).': Repair error: ' . $event->getMessage(), ['app' => 'updater']);
  418. }
  419. };
  420. $dispatcher->addListener(RepairStartEvent::class, $repairListener);
  421. $dispatcher->addListener(RepairAdvanceEvent::class, $repairListener);
  422. $dispatcher->addListener(RepairFinishEvent::class, $repairListener);
  423. $dispatcher->addListener(RepairStepEvent::class, $repairListener);
  424. $dispatcher->addListener(RepairInfoEvent::class, $repairListener);
  425. $dispatcher->addListener(RepairWarningEvent::class, $repairListener);
  426. $dispatcher->addListener(RepairErrorEvent::class, $repairListener);
  427. $this->listen('\OC\Updater', 'maintenanceEnabled', function () use ($log) {
  428. $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']);
  429. });
  430. $this->listen('\OC\Updater', 'maintenanceDisabled', function () use ($log) {
  431. $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']);
  432. });
  433. $this->listen('\OC\Updater', 'maintenanceActive', function () use ($log) {
  434. $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']);
  435. });
  436. $this->listen('\OC\Updater', 'updateEnd', function ($success) use ($log) {
  437. if ($success) {
  438. $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']);
  439. } else {
  440. $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']);
  441. }
  442. });
  443. $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($log) {
  444. $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']);
  445. });
  446. $this->listen('\OC\Updater', 'dbUpgrade', function () use ($log) {
  447. $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']);
  448. });
  449. $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($log) {
  450. $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
  451. });
  452. $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($log) {
  453. $log->debug('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  454. });
  455. $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($log) {
  456. $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']);
  457. });
  458. $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($log) {
  459. $log->debug('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  460. });
  461. $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) {
  462. $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']);
  463. });
  464. $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) {
  465. $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']);
  466. });
  467. $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) {
  468. $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']);
  469. });
  470. $this->listen('\OC\Updater', 'failure', function ($message) use ($log) {
  471. $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']);
  472. });
  473. $this->listen('\OC\Updater', 'setDebugLogLevel', function () use ($log) {
  474. $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']);
  475. });
  476. $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($log) {
  477. $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']);
  478. });
  479. $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($log) {
  480. $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']);
  481. });
  482. $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($log) {
  483. $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']);
  484. });
  485. }
  486. }