diff options
author | Georg Ehrke <developer@georgehrke.com> | 2014-06-04 16:29:41 +0200 |
---|---|---|
committer | Georg Ehrke <developer@georgehrke.com> | 2014-06-04 16:29:41 +0200 |
commit | 724d027f199f77c6e1442c03dba4b3363f973412 (patch) | |
tree | 52e239f783193639789b6cf0604c1b17546ebb38 /lib | |
parent | 2c00ab13cf1dca45035e88ecad854997f78cf51c (diff) | |
download | nextcloud-server-724d027f199f77c6e1442c03dba4b3363f973412.tar.gz nextcloud-server-724d027f199f77c6e1442c03dba4b3363f973412.zip |
add unit test
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/installer.php | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/lib/private/installer.php b/lib/private/installer.php index bbb8bc5a152..06677115c8e 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -164,21 +164,7 @@ 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 ) { - $appdata = OC_OCSClient::getApplication($app); - $download = OC_OCSClient::getApplicationDownload($app, 1); - - if (isset($download['downloadlink']) && trim($download['downloadlink']) !== '') { - $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); - $info = array( - 'source' => 'http', - 'href' => $download['downloadlink'], - 'appdata' => $appdata - ); - } else { - throw new \Exception('Could not fetch app info!'); - } - + public static function updateApp( $info=array() ) { list($extractDir, $path) = self::downloadApp($info); $info = self::checkAppsIntegrity($info, $extractDir, $path); @@ -206,6 +192,29 @@ class OC_Installer{ return OC_App::updateApp($info['id']); } + /** + * update an app by it's id + * @param integer $ocsid + * @return bool + * @throws Exception + */ + public static function updateAppByOCSId($ocsid) { + $appdata = OC_OCSClient::getApplication($ocsid); + $download = OC_OCSClient::getApplicationDownload($ocsid, 1); + + if (isset($download['downloadlink']) && trim($download['downloadlink']) !== '') { + $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); + $info = array( + 'source' => 'http', + 'href' => $download['downloadlink'], + 'appdata' => $appdata + ); + } else { + throw new \Exception('Could not fetch app info!'); + } + + return self::updateApp($info); + } /** * @param array $data @@ -322,7 +331,7 @@ class OC_Installer{ $version = trim($info['version']); } - if($version<>trim($data['appdata']['version'])) { + if(isset($data['appdata']['version']) && $version<>trim($data['appdata']['version'])) { OC_Helper::rmdirr($extractDir); throw new \Exception($l->t("App can't be installed because the version in info.xml/version is not the same as the version reported from the app store")); } |