From 6779f28af40c51a0bd3722eca2fd313130e1a367 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind@owncloud.com>
Date: Mon, 14 May 2012 22:49:20 +0200
Subject: [PATCH] cache app types during install or update

---
 apps/files/appinfo/version            |  2 +-
 apps/files_archive/appinfo/version    |  2 +-
 apps/files_encryption/appinfo/version |  2 +-
 apps/files_external/appinfo/version   |  2 +-
 apps/files_sharing/appinfo/version    |  2 +-
 apps/files_versions/appinfo/version   |  2 +-
 apps/user_openid/appinfo/version      |  2 +-
 lib/app.php                           | 25 +++++++++++++++----------
 lib/installer.php                     |  6 ++++++
 9 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/apps/files/appinfo/version b/apps/files/appinfo/version
index b123147e2a1..8cfbc905b39 100644
--- a/apps/files/appinfo/version
+++ b/apps/files/appinfo/version
@@ -1 +1 @@
-1.1
\ No newline at end of file
+1.1.1
\ No newline at end of file
diff --git a/apps/files_archive/appinfo/version b/apps/files_archive/appinfo/version
index ceab6e11ece..2f4536184bc 100644
--- a/apps/files_archive/appinfo/version
+++ b/apps/files_archive/appinfo/version
@@ -1 +1 @@
-0.1
\ No newline at end of file
+0.2
\ No newline at end of file
diff --git a/apps/files_encryption/appinfo/version b/apps/files_encryption/appinfo/version
index ceab6e11ece..2f4536184bc 100644
--- a/apps/files_encryption/appinfo/version
+++ b/apps/files_encryption/appinfo/version
@@ -1 +1 @@
-0.1
\ No newline at end of file
+0.2
\ No newline at end of file
diff --git a/apps/files_external/appinfo/version b/apps/files_external/appinfo/version
index ceab6e11ece..2f4536184bc 100644
--- a/apps/files_external/appinfo/version
+++ b/apps/files_external/appinfo/version
@@ -1 +1 @@
-0.1
\ No newline at end of file
+0.2
\ No newline at end of file
diff --git a/apps/files_sharing/appinfo/version b/apps/files_sharing/appinfo/version
index 2f4536184bc..7dff5b89211 100644
--- a/apps/files_sharing/appinfo/version
+++ b/apps/files_sharing/appinfo/version
@@ -1 +1 @@
-0.2
\ No newline at end of file
+0.2.1
\ No newline at end of file
diff --git a/apps/files_versions/appinfo/version b/apps/files_versions/appinfo/version
index afaf360d37f..7f207341d5d 100644
--- a/apps/files_versions/appinfo/version
+++ b/apps/files_versions/appinfo/version
@@ -1 +1 @@
-1.0.0
\ No newline at end of file
+1.0.1
\ No newline at end of file
diff --git a/apps/user_openid/appinfo/version b/apps/user_openid/appinfo/version
index ceab6e11ece..6da28dde76d 100644
--- a/apps/user_openid/appinfo/version
+++ b/apps/user_openid/appinfo/version
@@ -1 +1 @@
-0.1
\ No newline at end of file
+0.1.1
\ No newline at end of file
diff --git a/lib/app.php b/lib/app.php
index 04fa0ff495d..865be5c5a1e 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -114,19 +114,22 @@ class OC_App{
 			self::$appTypes=OC_Appconfig::getValues(false,'types');
 		}
 
-		//get it from info.xml if we haven't cached it
-		if(!isset(self::$appTypes[$app])){
-			$appData=self::getAppInfo($app);
-			if(isset($appData['types'])){
-				self::$appTypes[$app]=implode(',',$appData['types']);
-			}else{
-				self::$appTypes[$app]='';
-			}
+		return explode(',',self::$appTypes[$app]);
+	}
 
-			OC_Appconfig::setValue($app,'types',self::$appTypes[$app]);
+	/**
+	 * read app types from info.xml and cache them in the database
+	 */
+	public static function setAppTypes($app){
+		$appData=self::getAppInfo($app);
+		
+		if(isset($appData['types'])){
+			$appTypes=implode(',',$appData['types']);
+		}else{
+			$appTypes='';
 		}
 
-		return explode(',',self::$appTypes[$app]);
+		OC_Appconfig::setValue($app,'types',$appTypes);
 	}
 
 	/**
@@ -542,6 +545,8 @@ class OC_App{
 		foreach($appData['public'] as $name=>$path){
 			OCP\CONFIG::setAppValue('core', 'public_'.$name, '/apps/'.$appid.'/'.$path);
 		}
+
+		self::setAppTypes($appid);
 	}
 
 	/**
diff --git a/lib/installer.php b/lib/installer.php
index e1f30ebe272..731eaaa9030 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -193,6 +193,9 @@ class OC_Installer{
 		foreach($info['public'] as $name=>$path){
 			OCP\CONFIG::setAppValue('core', 'public_'.$name, '/apps/'.$info['id'].'/'.$path);
 		}
+
+		OC_App::setAppTypes($info['id']);
+		
 		return $info['id'];
 	}
 
@@ -318,6 +321,9 @@ class OC_Installer{
 		foreach($info['public'] as $name=>$path){
 			OCP\CONFIG::setAppValue('core', 'public_'.$name, '/apps/'.$app.'/'.$path);
 		}
+		
+		OC_App::setAppTypes($info['id']);
+		
 		return $info;
 	}
 
-- 
GitLab