summaryrefslogtreecommitdiffstats
path: root/lib/private/app.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-19 15:36:11 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-22 09:26:31 +0200
commit3aa77960ef78e397ae3e42d82aae32cac3114752 (patch)
treea0b11fd4e3c92a6bd0cbffa1efc0e2850011a1c9 /lib/private/app.php
parentd0030aad6cb108bbf4ca729d0e11f3438145aba9 (diff)
downloadnextcloud-server-3aa77960ef78e397ae3e42d82aae32cac3114752.tar.gz
nextcloud-server-3aa77960ef78e397ae3e42d82aae32cac3114752.zip
Adding pre- and post-migration repair steps
Diffstat (limited to 'lib/private/app.php')
-rw-r--r--lib/private/app.php35
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/private/app.php b/lib/private/app.php
index cf0ccbb2272..7bcbef32531 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -47,6 +47,7 @@
use OC\App\DependencyAnalyzer;
use OC\App\Platform;
use OC\OCSClient;
+use OC\Repair;
/**
* This class manages the apps. It allows them to register and integrate in the
@@ -1031,7 +1032,6 @@ class OC_App {
if (!empty($requireMax)
&& version_compare(self::adjustVersionParts($ocVersion, $requireMax), $requireMax, '>')
) {
-
return false;
}
@@ -1051,7 +1051,6 @@ class OC_App {
return $versions;
}
-
/**
* @param string $app
* @return bool
@@ -1148,9 +1147,12 @@ class OC_App {
if($appPath === false) {
return false;
}
+ $appData = self::getAppInfo($appId);
+ self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
if (file_exists($appPath . '/appinfo/database.xml')) {
OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
}
+ self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']);
unset(self::$appVersion[$appId]);
// run upgrade code
if (file_exists($appPath . '/appinfo/update.php')) {
@@ -1159,7 +1161,6 @@ class OC_App {
}
//set remote/public handlers
- $appData = self::getAppInfo($appId);
if (array_key_exists('ocsid', $appData)) {
\OC::$server->getConfig()->setAppValue($appId, 'ocsid', $appData['ocsid']);
} elseif(\OC::$server->getConfig()->getAppValue($appId, 'ocsid', null) !== null) {
@@ -1182,6 +1183,34 @@ class OC_App {
/**
* @param string $appId
+ * @param string[] $steps
+ * @throws \OC\NeedsUpdateException
+ */
+ private static function executeRepairSteps($appId, array $steps) {
+ if (empty($steps)) {
+ return;
+ }
+ // load the app
+ self::loadApp($appId, false);
+
+ $dispatcher = OC::$server->getEventDispatcher();
+
+ // load the steps
+ $r = new Repair([], $dispatcher);
+ foreach ($steps as $step) {
+ try {
+ $r->addStep($step);
+ } catch (Exception $ex) {
+ $r->emit('\OC\Repair', 'error', [$ex->getMessage()]);
+ \OC::$server->getLogger()->logException($ex);
+ }
+ }
+ // run the steps
+ $r->run();
+ }
+
+ /**
+ * @param string $appId
* @return \OC\Files\View|false
*/
public static function getStorage($appId) {