public function __construct(array $urlParams = []) { parent::__construct('updater', $urlParams); $container = $this->getContainer(); /** * Controllers */ $container->registerService('UpdateController', function ($c) { return new UpdateController($c->query('AppName'), $c->query('Request'), $c->query('L10N')); }); $container->registerService('BackupController', function ($c) { return new BackupController($c->query('AppName'), $c->query('Request'), $c->query('Config'), $c->query('L10N')); }); $container->registerService('AdminController', function ($c) { return new AdminController($c->query('AppName'), $c->query('Request'), $c->query('Config'), $c->query('L10N')); }); $container->registerService('L10N', function ($c) { return $c->query('ServerContainer')->getL10N($c->query('AppName')); }); $container->registerService('Config', function ($c) { return new Config($c->query('ServerContainer')->getConfig()); }); $container->registerService('Channel', function ($c) { return new Channel($c->query('L10N')); }); //Startup if (\OC_Util::getEditionString() === '') { \OCP\App::registerAdmin('updater', 'admin'); $appPath = $container->query('Config')->getBackupBase(); if (!@file_exists($appPath)) { Helper::mkdir($appPath); } } }
public function update($tmpDir = '') { Helper::mkdir($tmpDir, true); $this->collect(); try { foreach ($this->appsToUpdate as $appId) { if (!@file_exists($this->newBase . '/' . $appId)){ continue; } $path = \OC_App::getAppPath($appId); if ($path) { Helper::move($path, $tmpDir . '/' . $appId); // ! reverted intentionally $this->done [] = array( 'dst' => $path, 'src' => $tmpDir . '/' . $appId ); Helper::move($this->newBase . '/' . $appId, $path); } else { // The app is new and doesn't exist in the current instance $pathData = first(\OC::$APPSROOTS); Helper::move($this->newBase . '/' . $appId, $pathData['path'] . '/' . $appId); } } $this->finalize(); } catch (\Exception $e) { $this->rollback(true); throw $e; } }