Updater.php 21 KB

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