Skip to content

Commit

Permalink
Remove OC_App:installApp
Browse files Browse the repository at this point in the history
* uses Installer->installApp now
* removes unused code
* fixes #4453
* added some additional checks

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed May 15, 2017
1 parent 9ad57ca commit be33234
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 80 deletions.
28 changes: 27 additions & 1 deletion lib/private/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct(AppFetcher $appFetcher,
*
* @param string $appId App to install
* @throws \Exception
* @return integer
* @return string app ID
*/
public function installApp($appId) {
$app = \OC_App::findAppInDirectories($appId);
Expand All @@ -109,6 +109,29 @@ public function installApp($appId) {
$basedir = $app['path'].'/'.$appId;
$info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true);

$l = \OC::$server->getL10N('core');

if(!is_array($info)) {
throw new \Exception(
$l->t('App "%s" cannot be installed because appinfo file cannot be read.',
[$info['name']]
)
);
}

$version = \OCP\Util::getVersion();
if (!\OC_App::isAppCompatible($version, $info)) {
throw new \Exception(
// TODO $l
$l->t('App "%s" cannot be installed because it is not compatible with this version of the server.',
[$info['name']]
)
);
}

// check for required dependencies
\OC_App::checkAppDependencies($this->config, $l, $info);

//install the database
if(is_file($basedir.'/appinfo/database.xml')) {
if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) {
Expand All @@ -120,6 +143,9 @@ public function installApp($appId) {

\OC_App::registerAutoloading($appId, $basedir);
\OC_App::setupBackgroundJobs($info['background-jobs']);
if(isset($info['settings']) && is_array($info['settings'])) {
\OC::$server->getSettingsManager()->setupSettings($info['settings']);
}

//run appinfo/install.php
if((!isset($data['noinstall']) or $data['noinstall']==false)) {
Expand Down
29 changes: 2 additions & 27 deletions lib/private/legacy/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,6 @@ public static function isEnabled($app) {
public function enable($appId,
$groups = null) {
self::$enabledAppsCache = []; // flush
$l = \OC::$server->getL10N('core');
$config = \OC::$server->getConfig();

// Check if app is already downloaded
$installer = new Installer(
Expand All @@ -374,23 +372,7 @@ public function enable($appId,
$installer->downloadApp($appId);
}

if (!Installer::isInstalled($appId)) {
$appId = self::installApp(
$appId,
$config,
$l
);
$appPath = self::getAppPath($appId);
self::registerAutoloading($appId, $appPath);
$installer->installApp($appId);
} else {
// check for required dependencies
$info = self::getAppInfo($appId);
self::checkAppDependencies($config, $l, $info);
$appPath = self::getAppPath($appId);
self::registerAutoloading($appId, $appPath);
$installer->installApp($appId);
}
$installer->installApp($appId);

$appManager = \OC::$server->getAppManager();
if (!is_null($groups)) {
Expand All @@ -406,13 +388,6 @@ public function enable($appId,
} else {
$appManager->enableApp($appId);
}

$info = self::getAppInfo($appId);
if(isset($info['settings']) && is_array($info['settings'])) {
$appPath = self::getAppPath($appId);
self::registerAutoloading($appId, $appPath);
\OC::$server->getSettingsManager()->setupSettings($info['settings']);
}
}

/**
Expand Down Expand Up @@ -1258,7 +1233,7 @@ public static function parseAppInfo(array $data, $lang = null) {
* @param array $info
* @throws \Exception
*/
protected static function checkAppDependencies($config, $l, $info) {
public static function checkAppDependencies($config, $l, $info) {
$dependencyAnalyzer = new DependencyAnalyzer(new Platform($config), $l);
$missing = $dependencyAnalyzer->analyze($info);
if (!empty($missing)) {
Expand Down
52 changes: 0 additions & 52 deletions settings/ajax/installapp.php

This file was deleted.

0 comments on commit be33234

Please sign in to comment.