aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-02-22 16:00:26 +0100
committerMorris Jobke <hey@morrisjobke.de>2018-03-21 11:34:18 +0100
commit514de5dfa18d92d2f7bb15c9840d685b25300f4c (patch)
tree8a1538364a515507f60077a827de5fce07a1ae38
parent2d5febd0b9fe7f5b9e6a463fa877fef1148921c8 (diff)
downloadnextcloud-server-514de5dfa18d92d2f7bb15c9840d685b25300f4c.tar.gz
nextcloud-server-514de5dfa18d92d2f7bb15c9840d685b25300f4c.zip
Use isInstalled of AppManger instead of reimplement it
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
-rw-r--r--core/Command/App/Install.php1
-rw-r--r--lib/private/App/AppManager.php4
-rw-r--r--lib/private/Installer.php21
-rw-r--r--lib/private/legacy/app.php1
-rw-r--r--lib/public/App/IAppManager.php4
-rw-r--r--tests/lib/InstallerTest.php6
6 files changed, 17 insertions, 20 deletions
diff --git a/core/Command/App/Install.php b/core/Command/App/Install.php
index 4432a1f40ac..525b0095f04 100644
--- a/core/Command/App/Install.php
+++ b/core/Command/App/Install.php
@@ -58,6 +58,7 @@ class Install extends Command {
}
try {
+ /** @var Installer $installer */
$installer = \OC::$server->query(Installer::class);
$installer->downloadApp($appId);
$result = $installer->installApp($appId);
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php
index 81f1369cb5e..442fc1a0e1b 100644
--- a/lib/private/App/AppManager.php
+++ b/lib/private/App/AppManager.php
@@ -204,7 +204,9 @@ class AppManager implements IAppManager {
}
/**
- * Check if an app is installed in the instance
+ * Check if an app is enabled in the instance
+ *
+ * Notice: This actually checks if the app is enabled and not only if it is installed.
*
* @param string $appId
* @return bool
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index ab0ef836fbb..1b40b4955d6 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -166,17 +166,6 @@ class Installer {
}
/**
- * @brief checks whether or not an app is installed
- * @param string $app app
- * @returns bool
- *
- * Checks whether or not an app is installed, i.e. registered in apps table.
- */
- public static function isInstalled( $app ) {
- return (\OC::$server->getConfig()->getAppValue($app, "installed_version", null) !== null);
- }
-
- /**
* Updates the specified app from the appstore
*
* @param string $appId
@@ -510,17 +499,19 @@ class Installer {
* @return array Array of error messages (appid => Exception)
*/
public static function installShippedApps($softErrors = false) {
+ $appManager = \OC::$server->getAppManager();
+ $config = \OC::$server->getConfig();
$errors = [];
foreach(\OC::$APPSROOTS as $app_dir) {
if($dir = opendir( $app_dir['path'] )) {
while( false !== ( $filename = readdir( $dir ))) {
if( $filename[0] !== '.' and is_dir($app_dir['path']."/$filename") ) {
if( file_exists( $app_dir['path']."/$filename/appinfo/info.xml" )) {
- if(!Installer::isInstalled($filename)) {
+ if($config->getAppValue($filename, "installed_version", null) === null) {
$info=OC_App::getAppInfo($filename);
$enabled = isset($info['default_enable']);
- if (($enabled || in_array($filename, \OC::$server->getAppManager()->getAlwaysEnabledApps()))
- && \OC::$server->getConfig()->getAppValue($filename, 'enabled') !== 'no') {
+ if (($enabled || in_array($filename, $appManager->getAlwaysEnabledApps()))
+ && $config->getAppValue($filename, 'enabled') !== 'no') {
if ($softErrors) {
try {
Installer::installShippedApp($filename);
@@ -534,7 +525,7 @@ class Installer {
} else {
Installer::installShippedApp($filename);
}
- \OC::$server->getConfig()->setAppValue($filename, 'enabled', 'yes');
+ $config->setAppValue($filename, 'enabled', 'yes');
}
}
}
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index bc450ffa25d..cabeed1d62d 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -383,6 +383,7 @@ class OC_App {
array $groups = []) {
// Check if app is already downloaded
+ /** @var Installer $installer */
$installer = \OC::$server->query(Installer::class);
$isDownloaded = $installer->isDownloaded($appId);
diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php
index f0f14061e35..4840d71d756 100644
--- a/lib/public/App/IAppManager.php
+++ b/lib/public/App/IAppManager.php
@@ -67,7 +67,9 @@ interface IAppManager {
public function isEnabledForUser($appId, $user = null);
/**
- * Check if an app is installed in the instance
+ * Check if an app is enabled in the instance
+ *
+ * Notice: This actually checks if the app is enabled and not only if it is installed.
*
* @param string $appId
* @return bool
diff --git a/tests/lib/InstallerTest.php b/tests/lib/InstallerTest.php
index c7e4bfeacfb..824682740e2 100644
--- a/tests/lib/InstallerTest.php
+++ b/tests/lib/InstallerTest.php
@@ -103,9 +103,9 @@ class InstallerTest extends TestCase {
\OC::$server->getLogger(),
\OC::$server->getConfig()
);
- $installer->installApp(self::$appid);
- $isInstalled = Installer::isInstalled(self::$appid);
- $this->assertTrue($isInstalled);
+ $this->assertNull(\OC::$server->getConfig()->getAppValue('testapp', 'enabled', null), 'Check that the app is not listed before installation');
+ $this->assertSame('testapp', $installer->installApp(self::$appid));
+ $this->assertSame('no', \OC::$server->getConfig()->getAppValue('testapp', 'enabled', null), 'Check that the app is listed after installation');
$this->assertSame('0.9', \OC::$server->getConfig()->getAppValue('testapp', 'installed_version'));
$installer->removeApp(self::$appid);
}