From 3fa4b3abff5040a46720b2d11531d36a65e4836e Mon Sep 17 00:00:00 2001
From: root <root@oc.(none)>
Date: Wed, 30 Jan 2013 12:08:14 +0100
Subject: [PATCH] apps updater is now working

---
 lib/app.php       |  4 +---
 lib/installer.php | 28 +++++++++-------------------
 2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/lib/app.php b/lib/app.php
index 13f54d6cf7..52df04e73b 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -179,7 +179,7 @@ class OC_App{
 	 * This function checks whether or not an app is enabled.
 	 */
 	public static function isEnabled( $app ) {
-		if( 'files'==$app or 'yes' == OC_Appconfig::getValue( $app, 'enabled' )) {
+		if( 'files'==$app or ('yes' == OC_Appconfig::getValue( $app, 'enabled' ))) {
 			return true;
 		}
 
@@ -236,10 +236,8 @@ class OC_App{
 
 		// check if app is a shiped app or not. if not delete
 		if(!OC_App::isShipped( $app )){
-//			error_log($app.' not shipped');	
 			OC_Installer::removeApp( $app );
 		}else{
-//			error_log($app.' shipped');	
 		}		
 	}
 
diff --git a/lib/installer.php b/lib/installer.php
index f4094a5d4c..8cffe5f06c 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -155,16 +155,6 @@ class OC_Installer{
 			return false;
 		}
 
-		//check if an app with the same id is already installed
-		if(self::isInstalled( $info['id'] )) {
-			OC_Log::write('core', 'App already installed', OC_Log::WARN);
-			OC_Helper::rmdirr($extractDir);
-			if($data['source']=='http') {
-				unlink($path);
-			}
-			return false;
-		}
-
 		$basedir=OC_App::getInstallPath().'/'.$info['id'];
 		//check if the destination directory already exists
 		if(is_dir($basedir)) {
@@ -264,10 +254,9 @@ class OC_Installer{
 	 * upgrade.php can determine the current installed version of the app using "OC_Appconfig::getValue($appid, 'installed_version')"
 	 */
 	public static function updateApp( $app ) {
-		error_log('updater!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
-		return(true);
-        	if(OC_Installer::isDownloaded( $name )) { 
-		}
+		$ocsid=OC_Appconfig::getValue( $app, 'ocsid', '');
+		OC_App::disable($app);
+		OC_App::enable($ocsid);
 	}
 
         /**
@@ -278,19 +267,20 @@ class OC_Installer{
          * The function will check if an update for a version is available
          */
         public static function isUpdateAvailable( $app ) {
-		//debug
-		return('1.1');
 
 		$ocsid=OC_Appconfig::getValue( $app, 'ocsid', '');
 
 		if($ocsid<>''){
 		
 			$ocsdata=OC_OCSClient::getApplication($ocsid);
-			$ocsversion=$ocsdata['version'];
+			$ocsversion= (string) $ocsdata['version'];
 			$currentversion=OC_App::getAppVersion($app);
+			if($ocsversion<>$currentversion){
+				return($ocsversion);
 
-//error_log('bb'.$app.' '.$ocsversion);
-			return($ocsversion);
+			}else{
+				return('');
+			}
 
 		}else{
 			return('');
-- 
GitLab