From 05f1fffddc49678768c90104e6aeaeac2419d95d Mon Sep 17 00:00:00 2001
From: Frank Karlitschek <karlitschek@kde.org>
Date: Fri, 27 Jan 2012 17:34:47 +0100
Subject: [PATCH] fix appstore download.

---
 lib/app.php       |  2 +-
 lib/installer.php |  4 ++--
 settings/apps.php | 24 ++++++++++++++++--------
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/lib/app.php b/lib/app.php
index de7d82ce95..37a99823e3 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -100,7 +100,7 @@ class OC_App{
 			}else{
                                 $download=OC_OCSClient::getApplicationDownload($app,1);
 				if(isset($download['downloadlink']) and $download['downloadlink']<>'') {
-					OC_Installer::installApp(array('source'=>'http','href'=>$download['downloadlink']));
+					$app=OC_Installer::installApp(array('source'=>'http','href'=>$download['downloadlink']));
 				}
 			}
 		}
diff --git a/lib/installer.php b/lib/installer.php
index 9248f68e01..b2f817e702 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -152,14 +152,14 @@ class OC_Installer{
 		}
 		
 		//run appinfo/install.php
-		if(!isset($data['noinstall']) or $data['noinstall']==false and is_file($basedir.'/appinfo/install.php')){
+		if((!isset($data['noinstall']) or $data['noinstall']==false) and file_exists($basedir.'/appinfo/install.php')){
 			include($basedir.'/appinfo/install.php');
 		}
 		
 		//set the installed version
 		OC_Appconfig::setValue($info['id'],'installed_version',$info['version']);
 		OC_Appconfig::setValue($info['id'],'enabled','no');
-		return true;
+		return $info['id'];
 	}
 
 	/**
diff --git a/settings/apps.php b/settings/apps.php
index 40b72639cd..0889b0c45e 100644
--- a/settings/apps.php
+++ b/settings/apps.php
@@ -57,14 +57,22 @@ usort($apps, 'app_sort');
  	$categories=array_keys($catagoryNames);
  	$externalApps=OC_OCSClient::getApplications($categories);
  	foreach($externalApps as $app){
- 		$apps[]=array(
- 			'name'=>$app['name'],
- 			'id'=>$app['id'],
- 			'active'=>false,
- 			'description'=>$app['description'],
- 			'author'=>$app['personid'],
- 			'license'=>$app['license'],
- 		);
+		// show only external apps that are not exist yet
+		$local=false;
+ 		foreach($apps as $a){
+			if($a['name']==$app['name']) $local=true;			
+		}
+
+		if(!$local) {
+	 		$apps[]=array(
+ 				'name'=>$app['name'],
+ 				'id'=>$app['id'],
+ 				'active'=>false,
+ 				'description'=>$app['description'],
+ 				'author'=>$app['personid'],
+ 				'license'=>$app['license'],
+ 			);
+		}
  	}
  }
 
-- 
GitLab