Updater.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  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 OC\App\AppManager;
  41. use OC\DB\Connection;
  42. use OC\DB\MigrationService;
  43. use OC\Hooks\BasicEmitter;
  44. use OC\IntegrityCheck\Checker;
  45. use OC_App;
  46. use OCP\App\IAppManager;
  47. use OCP\IConfig;
  48. use OCP\ILogger;
  49. use OCP\Util;
  50. use Psr\Log\LoggerInterface;
  51. use Symfony\Component\EventDispatcher\GenericEvent;
  52. /**
  53. * Class that handles autoupdating of ownCloud
  54. *
  55. * Hooks provided in scope \OC\Updater
  56. * - maintenanceStart()
  57. * - maintenanceEnd()
  58. * - dbUpgrade()
  59. * - failure(string $message)
  60. */
  61. class Updater extends BasicEmitter {
  62. /** @var LoggerInterface */
  63. private $log;
  64. /** @var IConfig */
  65. private $config;
  66. /** @var Checker */
  67. private $checker;
  68. /** @var Installer */
  69. private $installer;
  70. private $logLevelNames = [
  71. 0 => 'Debug',
  72. 1 => 'Info',
  73. 2 => 'Warning',
  74. 3 => 'Error',
  75. 4 => 'Fatal',
  76. ];
  77. public function __construct(IConfig $config,
  78. Checker $checker,
  79. ?LoggerInterface $log,
  80. Installer $installer) {
  81. $this->log = $log;
  82. $this->config = $config;
  83. $this->checker = $checker;
  84. $this->installer = $installer;
  85. }
  86. /**
  87. * runs the update actions in maintenance mode, does not upgrade the source files
  88. * except the main .htaccess file
  89. *
  90. * @return bool true if the operation succeeded, false otherwise
  91. */
  92. public function upgrade(): bool {
  93. $this->emitRepairEvents();
  94. $this->logAllEvents();
  95. $logLevel = $this->config->getSystemValue('loglevel', ILogger::WARN);
  96. $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  97. $this->config->setSystemValue('loglevel', ILogger::DEBUG);
  98. $wasMaintenanceModeEnabled = $this->config->getSystemValueBool('maintenance');
  99. if (!$wasMaintenanceModeEnabled) {
  100. $this->config->setSystemValue('maintenance', true);
  101. $this->emit('\OC\Updater', 'maintenanceEnabled');
  102. }
  103. // Clear CAN_INSTALL file if not on git
  104. if (\OC_Util::getChannel() !== 'git' && is_file(\OC::$configDir.'/CAN_INSTALL')) {
  105. if (!unlink(\OC::$configDir . '/CAN_INSTALL')) {
  106. $this->log->error('Could not cleanup CAN_INSTALL from your config folder. Please remove this file manually.');
  107. }
  108. }
  109. $installedVersion = $this->config->getSystemValue('version', '0.0.0');
  110. $currentVersion = implode('.', \OCP\Util::getVersion());
  111. $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, ['app' => 'core']);
  112. $success = true;
  113. try {
  114. $this->doUpgrade($currentVersion, $installedVersion);
  115. } catch (HintException $exception) {
  116. $this->log->error($exception->getMessage(), [
  117. 'exception' => $exception,
  118. ]);
  119. $this->emit('\OC\Updater', 'failure', [$exception->getMessage() . ': ' .$exception->getHint()]);
  120. $success = false;
  121. } catch (\Exception $exception) {
  122. $this->log->error($exception->getMessage(), [
  123. 'exception' => $exception,
  124. ]);
  125. $this->emit('\OC\Updater', 'failure', [get_class($exception) . ': ' .$exception->getMessage()]);
  126. $success = false;
  127. }
  128. $this->emit('\OC\Updater', 'updateEnd', [$success]);
  129. if (!$wasMaintenanceModeEnabled && $success) {
  130. $this->config->setSystemValue('maintenance', false);
  131. $this->emit('\OC\Updater', 'maintenanceDisabled');
  132. } else {
  133. $this->emit('\OC\Updater', 'maintenanceActive');
  134. }
  135. $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]);
  136. $this->config->setSystemValue('loglevel', $logLevel);
  137. $this->config->setSystemValue('installed', true);
  138. return $success;
  139. }
  140. /**
  141. * Return version from which this version is allowed to upgrade from
  142. *
  143. * @return array allowed previous versions per vendor
  144. */
  145. private function getAllowedPreviousVersions(): array {
  146. // this should really be a JSON file
  147. require \OC::$SERVERROOT . '/version.php';
  148. /** @var array $OC_VersionCanBeUpgradedFrom */
  149. return $OC_VersionCanBeUpgradedFrom;
  150. }
  151. /**
  152. * Return vendor from which this version was published
  153. *
  154. * @return string Get the vendor
  155. */
  156. private function getVendor(): string {
  157. // this should really be a JSON file
  158. require \OC::$SERVERROOT . '/version.php';
  159. /** @var string $vendor */
  160. return (string) $vendor;
  161. }
  162. /**
  163. * Whether an upgrade to a specified version is possible
  164. * @param string $oldVersion
  165. * @param string $newVersion
  166. * @param array $allowedPreviousVersions
  167. * @return bool
  168. */
  169. public function isUpgradePossible(string $oldVersion, string $newVersion, array $allowedPreviousVersions): bool {
  170. $version = explode('.', $oldVersion);
  171. $majorMinor = $version[0] . '.' . $version[1];
  172. $currentVendor = $this->config->getAppValue('core', 'vendor', '');
  173. // Vendor was not set correctly on install, so we have to white-list known versions
  174. if ($currentVendor === '' && (
  175. isset($allowedPreviousVersions['owncloud'][$oldVersion]) ||
  176. isset($allowedPreviousVersions['owncloud'][$majorMinor])
  177. )) {
  178. $currentVendor = 'owncloud';
  179. $this->config->setAppValue('core', 'vendor', $currentVendor);
  180. }
  181. if ($currentVendor === 'nextcloud') {
  182. return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
  183. && (version_compare($oldVersion, $newVersion, '<=') ||
  184. $this->config->getSystemValue('debug', false));
  185. }
  186. // Check if the instance can be migrated
  187. return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) ||
  188. isset($allowedPreviousVersions[$currentVendor][$oldVersion]);
  189. }
  190. /**
  191. * runs the update actions in maintenance mode, does not upgrade the source files
  192. * except the main .htaccess file
  193. *
  194. * @param string $currentVersion current version to upgrade to
  195. * @param string $installedVersion previous version from which to upgrade from
  196. *
  197. * @throws \Exception
  198. */
  199. private function doUpgrade(string $currentVersion, string $installedVersion): void {
  200. // Stop update if the update is over several major versions
  201. $allowedPreviousVersions = $this->getAllowedPreviousVersions();
  202. if (!$this->isUpgradePossible($installedVersion, $currentVersion, $allowedPreviousVersions)) {
  203. throw new \Exception('Updates between multiple major versions and downgrades are unsupported.');
  204. }
  205. // Update .htaccess files
  206. try {
  207. Setup::updateHtaccess();
  208. Setup::protectDataDirectory();
  209. } catch (\Exception $e) {
  210. throw new \Exception($e->getMessage());
  211. }
  212. // create empty file in data dir, so we can later find
  213. // out that this is indeed an ownCloud data directory
  214. // (in case it didn't exist before)
  215. file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
  216. // pre-upgrade repairs
  217. $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher(), \OC::$server->get(LoggerInterface::class));
  218. $repair->run();
  219. $this->doCoreUpgrade();
  220. try {
  221. // TODO: replace with the new repair step mechanism https://github.com/owncloud/core/pull/24378
  222. Setup::installBackgroundJobs();
  223. } catch (\Exception $e) {
  224. throw new \Exception($e->getMessage());
  225. }
  226. // update all shipped apps
  227. $this->checkAppsRequirements();
  228. $this->doAppUpgrade();
  229. // Update the appfetchers version so it downloads the correct list from the appstore
  230. \OC::$server->getAppFetcher()->setVersion($currentVersion);
  231. /** @var IAppManager|AppManager $appManager */
  232. $appManager = \OC::$server->getAppManager();
  233. // upgrade appstore apps
  234. $this->upgradeAppStoreApps($appManager->getInstalledApps());
  235. $autoDisabledApps = $appManager->getAutoDisabledApps();
  236. if (!empty($autoDisabledApps)) {
  237. $this->upgradeAppStoreApps(array_keys($autoDisabledApps), $autoDisabledApps);
  238. }
  239. // install new shipped apps on upgrade
  240. $errors = Installer::installShippedApps(true);
  241. foreach ($errors as $appId => $exception) {
  242. /** @var \Exception $exception */
  243. $this->log->error($exception->getMessage(), [
  244. 'exception' => $exception,
  245. 'app' => $appId,
  246. ]);
  247. $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]);
  248. }
  249. // post-upgrade repairs
  250. $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher(), \OC::$server->get(LoggerInterface::class));
  251. $repair->run();
  252. //Invalidate update feed
  253. $this->config->setAppValue('core', 'lastupdatedat', 0);
  254. // Check for code integrity if not disabled
  255. if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) {
  256. $this->emit('\OC\Updater', 'startCheckCodeIntegrity');
  257. $this->checker->runInstanceVerification();
  258. $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity');
  259. }
  260. // only set the final version if everything went well
  261. $this->config->setSystemValue('version', implode('.', Util::getVersion()));
  262. $this->config->setAppValue('core', 'vendor', $this->getVendor());
  263. }
  264. protected function doCoreUpgrade(): void {
  265. $this->emit('\OC\Updater', 'dbUpgradeBefore');
  266. // execute core migrations
  267. $ms = new MigrationService('core', \OC::$server->get(Connection::class));
  268. $ms->migrate();
  269. $this->emit('\OC\Updater', 'dbUpgrade');
  270. }
  271. /**
  272. * upgrades all apps within a major ownCloud upgrade. Also loads "priority"
  273. * (types authentication, filesystem, logging, in that order) afterwards.
  274. *
  275. * @throws NeedsUpdateException
  276. */
  277. protected function doAppUpgrade(): void {
  278. $apps = \OC_App::getEnabledApps();
  279. $priorityTypes = ['authentication', 'filesystem', 'logging'];
  280. $pseudoOtherType = 'other';
  281. $stacks = [$pseudoOtherType => []];
  282. foreach ($apps as $appId) {
  283. $priorityType = false;
  284. foreach ($priorityTypes as $type) {
  285. if (!isset($stacks[$type])) {
  286. $stacks[$type] = [];
  287. }
  288. if (\OC_App::isType($appId, [$type])) {
  289. $stacks[$type][] = $appId;
  290. $priorityType = true;
  291. break;
  292. }
  293. }
  294. if (!$priorityType) {
  295. $stacks[$pseudoOtherType][] = $appId;
  296. }
  297. }
  298. foreach (array_merge($priorityTypes, [$pseudoOtherType]) as $type) {
  299. $stack = $stacks[$type];
  300. foreach ($stack as $appId) {
  301. if (\OC_App::shouldUpgrade($appId)) {
  302. $this->emit('\OC\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]);
  303. \OC_App::updateApp($appId);
  304. $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]);
  305. }
  306. if ($type !== $pseudoOtherType) {
  307. // load authentication, filesystem and logging apps after
  308. // upgrading them. Other apps my need to rely on modifying
  309. // user and/or filesystem aspects.
  310. \OC_App::loadApp($appId);
  311. }
  312. }
  313. }
  314. }
  315. /**
  316. * check if the current enabled apps are compatible with the current
  317. * ownCloud version. disable them if not.
  318. * This is important if you upgrade ownCloud and have non ported 3rd
  319. * party apps installed.
  320. *
  321. * @return array
  322. * @throws \Exception
  323. */
  324. private function checkAppsRequirements(): array {
  325. $isCoreUpgrade = $this->isCodeUpgrade();
  326. $apps = OC_App::getEnabledApps();
  327. $version = implode('.', Util::getVersion());
  328. $disabledApps = [];
  329. $appManager = \OC::$server->getAppManager();
  330. foreach ($apps as $app) {
  331. // check if the app is compatible with this version of Nextcloud
  332. $info = OC_App::getAppInfo($app);
  333. if ($info === null || !OC_App::isAppCompatible($version, $info)) {
  334. if ($appManager->isShipped($app)) {
  335. throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update');
  336. }
  337. \OC::$server->getAppManager()->disableApp($app, true);
  338. $this->emit('\OC\Updater', 'incompatibleAppDisabled', [$app]);
  339. }
  340. // no need to disable any app in case this is a non-core upgrade
  341. if (!$isCoreUpgrade) {
  342. continue;
  343. }
  344. // shipped apps will remain enabled
  345. if ($appManager->isShipped($app)) {
  346. continue;
  347. }
  348. // authentication and session apps will remain enabled as well
  349. if (OC_App::isType($app, ['session', 'authentication'])) {
  350. continue;
  351. }
  352. }
  353. return $disabledApps;
  354. }
  355. /**
  356. * @return bool
  357. */
  358. private function isCodeUpgrade(): bool {
  359. $installedVersion = $this->config->getSystemValue('version', '0.0.0');
  360. $currentVersion = implode('.', Util::getVersion());
  361. if (version_compare($currentVersion, $installedVersion, '>')) {
  362. return true;
  363. }
  364. return false;
  365. }
  366. /**
  367. * @param array $apps
  368. * @param array $previousEnableStates
  369. * @throws \Exception
  370. */
  371. private function upgradeAppStoreApps(array $apps, array $previousEnableStates = []): void {
  372. foreach ($apps as $app) {
  373. try {
  374. $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
  375. if ($this->installer->isUpdateAvailable($app)) {
  376. $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]);
  377. $this->installer->updateAppstoreApp($app);
  378. }
  379. $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
  380. if (!empty($previousEnableStates)) {
  381. $ocApp = new \OC_App();
  382. if (!empty($previousEnableStates[$app]) && is_array($previousEnableStates[$app])) {
  383. $ocApp->enable($app, $previousEnableStates[$app]);
  384. } else {
  385. $ocApp->enable($app);
  386. }
  387. }
  388. } catch (\Exception $ex) {
  389. $this->log->error($ex->getMessage(), [
  390. 'exception' => $ex,
  391. ]);
  392. }
  393. }
  394. }
  395. /**
  396. * Forward messages emitted by the repair routine
  397. */
  398. private function emitRepairEvents(): void {
  399. $dispatcher = \OC::$server->getEventDispatcher();
  400. $dispatcher->addListener('\OC\Repair::warning', function ($event) {
  401. if ($event instanceof GenericEvent) {
  402. $this->emit('\OC\Updater', 'repairWarning', $event->getArguments());
  403. }
  404. });
  405. $dispatcher->addListener('\OC\Repair::error', function ($event) {
  406. if ($event instanceof GenericEvent) {
  407. $this->emit('\OC\Updater', 'repairError', $event->getArguments());
  408. }
  409. });
  410. $dispatcher->addListener('\OC\Repair::info', function ($event) {
  411. if ($event instanceof GenericEvent) {
  412. $this->emit('\OC\Updater', 'repairInfo', $event->getArguments());
  413. }
  414. });
  415. $dispatcher->addListener('\OC\Repair::step', function ($event) {
  416. if ($event instanceof GenericEvent) {
  417. $this->emit('\OC\Updater', 'repairStep', $event->getArguments());
  418. }
  419. });
  420. }
  421. private function logAllEvents(): void {
  422. $log = $this->log;
  423. $dispatcher = \OC::$server->getEventDispatcher();
  424. $dispatcher->addListener('\OC\DB\Migrator::executeSql', function ($event) use ($log) {
  425. if (!$event instanceof GenericEvent) {
  426. return;
  427. }
  428. $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
  429. });
  430. $dispatcher->addListener('\OC\DB\Migrator::checkTable', function ($event) use ($log) {
  431. if (!$event instanceof GenericEvent) {
  432. return;
  433. }
  434. $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']);
  435. });
  436. $repairListener = function ($event) use ($log) {
  437. if (!$event instanceof GenericEvent) {
  438. return;
  439. }
  440. switch ($event->getSubject()) {
  441. case '\OC\Repair::startProgress':
  442. $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
  443. break;
  444. case '\OC\Repair::advance':
  445. $desc = $event->getArgument(1);
  446. if (empty($desc)) {
  447. $desc = '';
  448. }
  449. $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']);
  450. break;
  451. case '\OC\Repair::finishProgress':
  452. $log->info('\OC\Repair::finishProgress', ['app' => 'updater']);
  453. break;
  454. case '\OC\Repair::step':
  455. $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']);
  456. break;
  457. case '\OC\Repair::info':
  458. $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']);
  459. break;
  460. case '\OC\Repair::warning':
  461. $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']);
  462. break;
  463. case '\OC\Repair::error':
  464. $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']);
  465. break;
  466. }
  467. };
  468. $dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
  469. $dispatcher->addListener('\OC\Repair::advance', $repairListener);
  470. $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
  471. $dispatcher->addListener('\OC\Repair::step', $repairListener);
  472. $dispatcher->addListener('\OC\Repair::info', $repairListener);
  473. $dispatcher->addListener('\OC\Repair::warning', $repairListener);
  474. $dispatcher->addListener('\OC\Repair::error', $repairListener);
  475. $this->listen('\OC\Updater', 'maintenanceEnabled', function () use ($log) {
  476. $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']);
  477. });
  478. $this->listen('\OC\Updater', 'maintenanceDisabled', function () use ($log) {
  479. $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']);
  480. });
  481. $this->listen('\OC\Updater', 'maintenanceActive', function () use ($log) {
  482. $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']);
  483. });
  484. $this->listen('\OC\Updater', 'updateEnd', function ($success) use ($log) {
  485. if ($success) {
  486. $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']);
  487. } else {
  488. $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']);
  489. }
  490. });
  491. $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use ($log) {
  492. $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']);
  493. });
  494. $this->listen('\OC\Updater', 'dbUpgrade', function () use ($log) {
  495. $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']);
  496. });
  497. $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($log) {
  498. $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']);
  499. });
  500. $this->listen('\OC\Updater', 'checkAppStoreAppBefore', function ($app) use ($log) {
  501. $log->debug('\OC\Updater::checkAppStoreAppBefore: Checking for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  502. });
  503. $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($log) {
  504. $log->info('\OC\Updater::upgradeAppStoreApp: Update app "' . $app . '" from appstore', ['app' => 'updater']);
  505. });
  506. $this->listen('\OC\Updater', 'checkAppStoreApp', function ($app) use ($log) {
  507. $log->debug('\OC\Updater::checkAppStoreApp: Checked for update of app "' . $app . '" in appstore', ['app' => 'updater']);
  508. });
  509. $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) {
  510. $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']);
  511. });
  512. $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) {
  513. $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']);
  514. });
  515. $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) {
  516. $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']);
  517. });
  518. $this->listen('\OC\Updater', 'failure', function ($message) use ($log) {
  519. $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']);
  520. });
  521. $this->listen('\OC\Updater', 'setDebugLogLevel', function () use ($log) {
  522. $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']);
  523. });
  524. $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use ($log) {
  525. $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']);
  526. });
  527. $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use ($log) {
  528. $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']);
  529. });
  530. $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use ($log) {
  531. $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']);
  532. });
  533. }
  534. }