[Pkg-owncloud-commits] [owncloud] 96/121: Throw an exception when we try to load an app that needs to be upgraded

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 16:44:39 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 9173a661bd433b22cb355f42c7727c22aeaa3c3b
Author: Robin Appelman <icewind at owncloud.com>
Date:   Thu Jul 24 17:16:34 2014 +0200

    Throw an exception when we try to load an app that needs to be upgraded
---
 lib/private/app.php                         | 38 +++--------------------------
 lib/private/needsupdateexception.php        | 12 +++++++++
 lib/private/serviceunavailableexception.php | 12 +++++++++
 3 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/lib/private/app.php b/lib/private/app.php
index 2887961..9fc0799 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -81,10 +81,13 @@ class OC_App {
 	 * load a single app
 	 *
 	 * @param string $app
+	 * @throws \OC\NeedsUpdateException
 	 */
 	public static function loadApp($app) {
 		if (is_file(self::getAppPath($app) . '/appinfo/app.php')) {
-			self::checkUpgrade($app);
+			if (self::shouldUpgrade($app)) {
+				throw new \OC\NeedsUpdateException();
+			}
 			require_once $app . '/appinfo/app.php';
 		}
 	}
@@ -957,39 +960,6 @@ class OC_App {
 	}
 
 	/**
-	 * check if the app needs updating and update when needed
-	 *
-	 * @param string $app
-	 */
-	public static function checkUpgrade($app) {
-		if (in_array($app, self::$checkedApps)) {
-			return;
-		}
-		self::$checkedApps[] = $app;
-		if (!self::shouldUpgrade($app)) {
-			return;
-		}
-		$versions = self::getAppVersions();
-		$installedVersion = $versions[$app];
-		$currentVersion = OC_App::getAppVersion($app);
-		OC_Log::write(
-			$app,
-			'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion,
-			OC_Log::DEBUG
-		);
-		$info = self::getAppInfo($app);
-		try {
-			OC_App::updateApp($app);
-			OC_Hook::emit('update', 'success', 'Updated ' . $info['name'] . ' app');
-		} catch (Exception $e) {
-			OC_Hook::emit('update', 'failure', 'Failed to update ' . $info['name'] . ' app: ' . $e->getMessage());
-			$l = OC_L10N::get('lib');
-			throw new RuntimeException($l->t('Failed to upgrade "%s".', array($app)), 0, $e);
-		}
-		OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
-	}
-
-	/**
 	 * check if the current enabled apps are compatible with the current
 	 * ownCloud version. disable them if not.
 	 * This is important if you upgrade ownCloud and have non ported 3rd
diff --git a/lib/private/needsupdateexception.php b/lib/private/needsupdateexception.php
new file mode 100644
index 0000000..bab928d
--- /dev/null
+++ b/lib/private/needsupdateexception.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind at owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC;
+
+class NeedsUpdateException extends ServiceUnavailableException {
+}
diff --git a/lib/private/serviceunavailableexception.php b/lib/private/serviceunavailableexception.php
new file mode 100644
index 0000000..15e4cd5
--- /dev/null
+++ b/lib/private/serviceunavailableexception.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind at owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC;
+
+class ServiceUnavailableException extends \Exception {
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list