summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/App/InfoParser.php12
-rw-r--r--lib/private/legacy/app.php2
-rw-r--r--lib/private/legacy/installer.php51
-rw-r--r--tests/data/app/expected-info.json4
4 files changed, 33 insertions, 36 deletions
diff --git a/lib/private/App/InfoParser.php b/lib/private/App/InfoParser.php
index b7540c04248..21422d40603 100644
--- a/lib/private/App/InfoParser.php
+++ b/lib/private/App/InfoParser.php
@@ -74,6 +74,9 @@ class InfoParser {
if (!array_key_exists('repair-steps', $array)) {
$array['repair-steps'] = [];
}
+ if (!array_key_exists('install', $array['repair-steps'])) {
+ $array['repair-steps']['install'] = [];
+ }
if (!array_key_exists('pre-migration', $array['repair-steps'])) {
$array['repair-steps']['pre-migration'] = [];
}
@@ -83,6 +86,9 @@ class InfoParser {
if (!array_key_exists('live-migration', $array['repair-steps'])) {
$array['repair-steps']['live-migration'] = [];
}
+ if (!array_key_exists('uninstall', $array['repair-steps'])) {
+ $array['repair-steps']['uninstall'] = [];
+ }
if (array_key_exists('documentation', $array) && is_array($array['documentation'])) {
foreach ($array['documentation'] as $key => $url) {
@@ -107,6 +113,9 @@ class InfoParser {
$array['types'] = [];
}
}
+ if (isset($array['repair-steps']['install']['step']) && is_array($array['repair-steps']['install']['step'])) {
+ $array['repair-steps']['install'] = $array['repair-steps']['install']['step'];
+ }
if (isset($array['repair-steps']['pre-migration']['step']) && is_array($array['repair-steps']['pre-migration']['step'])) {
$array['repair-steps']['pre-migration'] = $array['repair-steps']['pre-migration']['step'];
}
@@ -116,6 +125,9 @@ class InfoParser {
if (isset($array['repair-steps']['live-migration']['step']) && is_array($array['repair-steps']['live-migration']['step'])) {
$array['repair-steps']['live-migration'] = $array['repair-steps']['live-migration']['step'];
}
+ if (isset($array['repair-steps']['uninstall']['step']) && is_array($array['repair-steps']['uninstall']['step'])) {
+ $array['repair-steps']['uninstall'] = $array['repair-steps']['uninstall']['step'];
+ }
return $array;
}
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index 246bf97ee91..a1d4b7ce266 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -1187,7 +1187,7 @@ class OC_App {
* @param string[] $steps
* @throws \OC\NeedsUpdateException
*/
- private static function executeRepairSteps($appId, array $steps) {
+ public static function executeRepairSteps($appId, array $steps) {
if (empty($steps)) {
return;
}
diff --git a/lib/private/legacy/installer.php b/lib/private/legacy/installer.php
index 24c79b2dd8c..2bf95f33195 100644
--- a/lib/private/legacy/installer.php
+++ b/lib/private/legacy/installer.php
@@ -45,7 +45,7 @@ use OC\OCSClient;
/**
* This class provides the functionality needed to install, update and remove plugins/apps
*/
-class OC_Installer{
+class OC_Installer {
/**
*
@@ -134,16 +134,19 @@ class OC_Installer{
self::includeAppScript($basedir . '/appinfo/install.php');
}
+ $appData = OC_App::getAppInfo($appId);
+ OC_App::executeRepairSteps($appId, $appData['repair-steps']['install']);
+
//set the installed version
\OC::$server->getAppConfig()->setValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id']));
\OC::$server->getAppConfig()->setValue($info['id'], 'enabled', 'no');
//set remote/public handelers
foreach($info['remote'] as $name=>$path) {
- OCP\CONFIG::setAppValue('core', 'remote_'.$name, $info['id'].'/'.$path);
+ OCP\Config::setAppValue('core', 'remote_'.$name, $info['id'].'/'.$path);
}
foreach($info['public'] as $name=>$path) {
- OCP\CONFIG::setAppValue('core', 'public_'.$name, $info['id'].'/'.$path);
+ OCP\Config::setAppValue('core', 'public_'.$name, $info['id'].'/'.$path);
}
OC_App::setAppTypes($info['id']);
@@ -474,52 +477,30 @@ class OC_Installer{
/**
* Removes an app
* @param string $name name of the application to remove
- * @param array $options options
* @return boolean
*
- * This function removes an app. $options is an associative array. The
- * following keys are optional:ja
- * - keeppreferences: boolean, if true the user preferences won't be deleted
- * - keepappconfig: boolean, if true the config will be kept
- * - keeptables: boolean, if true the database will be kept
- * - keepfiles: boolean, if true the user files will be kept
*
* This function works as follows
- * -# including appinfo/remove.php
+ * -# call uninstall repair steps
* -# removing the files
*
* The function will not delete preferences, tables and the configuration,
* this has to be done by the function oc_app_uninstall().
*/
- public static function removeApp( $name, $options = array()) {
-
- if(isset($options['keeppreferences']) and $options['keeppreferences']==false ) {
- // todo
- // remove preferences
- }
-
- if(isset($options['keepappconfig']) and $options['keepappconfig']==false ) {
- // todo
- // remove app config
- }
-
- if(isset($options['keeptables']) and $options['keeptables']==false ) {
- // todo
- // remove app database tables
- }
+ public static function removeApp($appId) {
- if(isset($options['keepfiles']) and $options['keepfiles']==false ) {
- // todo
- // remove user files
+ $appData = OC_App::getAppInfo($appId);
+ if (!is_null($appData)) {
+ OC_App::executeRepairSteps($appId, $appData['repair-steps']['uninstall']);
}
- if(OC_Installer::isDownloaded( $name )) {
- $appdir=OC_App::getInstallPath().'/'.$name;
- OC_Helper::rmdirr($appdir);
+ if(OC_Installer::isDownloaded( $appId )) {
+ $appDir=OC_App::getInstallPath() . '/' . $appId;
+ OC_Helper::rmdirr($appDir);
return true;
}else{
- \OCP\Util::writeLog('core', 'can\'t remove app '.$name.'. It is not installed.', \OCP\Util::ERROR);
+ \OCP\Util::writeLog('core', 'can\'t remove app '.$appId.'. It is not installed.', \OCP\Util::ERROR);
return false;
}
@@ -590,6 +571,8 @@ class OC_Installer{
return false;
}
+ OC_App::executeRepairSteps($app, $info['repair-steps']['install']);
+
$config = \OC::$server->getConfig();
$config->setAppValue($app, 'installed_version', OC_App::getAppVersion($app));
diff --git a/tests/data/app/expected-info.json b/tests/data/app/expected-info.json
index 51d0c00ccef..cef7a7fdaba 100644
--- a/tests/data/app/expected-info.json
+++ b/tests/data/app/expected-info.json
@@ -69,8 +69,10 @@
}
},
"repair-steps": {
+ "install": [],
"pre-migration": [],
"post-migration": [],
- "live-migration": []
+ "live-migration": [],
+ "uninstall": []
}
}