public function testUpdateApp() { $pathOfOldTestApp = __DIR__; $pathOfOldTestApp .= '/../data/'; $pathOfOldTestApp .= 'testapp.zip'; $oldTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip'); OC_Helper::copyr($pathOfOldTestApp, $oldTmp); $oldData = array('path' => $oldTmp, 'source' => 'path', 'appdata' => ['id' => 'Bar', 'level' => 100]); $pathOfNewTestApp = __DIR__; $pathOfNewTestApp .= '/../data/'; $pathOfNewTestApp .= 'testapp2.zip'; $newTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip'); OC_Helper::copyr($pathOfNewTestApp, $newTmp); $newData = array('path' => $newTmp, 'source' => 'path', 'appdata' => ['id' => 'Bar', 'level' => 100]); OC_Installer::installApp($oldData); $oldVersionNumber = OC_App::getAppVersion(self::$appid); OC_Installer::updateApp($newData); $newVersionNumber = OC_App::getAppVersion(self::$appid); $this->assertNotEquals($oldVersionNumber, $newVersionNumber); }
public function testUpdateApp() { $pathOfOldTestApp = __DIR__; $pathOfOldTestApp .= '/../data/'; $pathOfOldTestApp .= 'testapp.zip'; $oldTmp = OC_Helper::tmpFile('.zip'); OC_Helper::copyr($pathOfOldTestApp, $oldTmp); $oldData = array('path' => $oldTmp, 'source' => 'path'); $pathOfNewTestApp = __DIR__; $pathOfNewTestApp .= '/../data/'; $pathOfNewTestApp .= 'testapp2.zip'; $newTmp = OC_Helper::tmpFile('.zip'); OC_Helper::copyr($pathOfNewTestApp, $newTmp); $newData = array('path' => $newTmp, 'source' => 'path'); OC_Installer::installApp($oldData); $oldVersionNumber = OC_App::getAppVersion(self::$appid); OC_Installer::updateApp($newData); $newVersionNumber = OC_App::getAppVersion(self::$appid); $this->assertNotEquals($oldVersionNumber, $newVersionNumber); }
/** * @param string $app * @return int */ public static function downloadApp($app) { $appData = OC_OCSClient::getApplication($app); $download = OC_OCSClient::getApplicationDownload($app, 1); if (isset($download['downloadlink']) and $download['downloadlink'] != '') { // Replace spaces in download link without encoding entire URL $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); $info = array('source' => 'http', 'href' => $download['downloadlink'], 'appdata' => $appData); $app = OC_Installer::installApp($info); } return $app; }
/** * @param string $app * @return int */ private static function downloadApp($app) { $ocsClient = new OCSClient(\OC::$server->getHTTPClientService(), \OC::$server->getConfig(), \OC::$server->getLogger()); $appData = $ocsClient->getApplication($app, \OCP\Util::getVersion()); $download = $ocsClient->getApplicationDownload($app, \OCP\Util::getVersion()); if (isset($download['downloadlink']) and $download['downloadlink'] != '') { // Replace spaces in download link without encoding entire URL $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); $info = array('source' => 'http', 'href' => $download['downloadlink'], 'appdata' => $appData); $app = OC_Installer::installApp($info); } return $app; }
/** * @brief enables an app * @param mixed $app app * @throws \Exception * @return void * * This function set an app as enabled in appconfig. */ public static function enable($app) { self::$enabledAppsCache = array(); // flush if (!OC_Installer::isInstalled($app)) { // check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string if (!is_numeric($app)) { $app = OC_Installer::installShippedApp($app); } else { $appdata = OC_OCSClient::getApplication($app, \OC_Util::getVersion()); $download = OC_OCSClient::getApplicationDownload($app, 1, \OC_Util::getVersion()); if (isset($download['downloadlink']) and $download['downloadlink'] != '') { $info = array('source' => 'http', 'href' => $download['downloadlink'], 'appdata' => $appdata); $app = OC_Installer::installApp($info); } } } $l = OC_L10N::get('core'); if ($app !== false) { // check if the app is compatible with this version of ownCloud $info = OC_App::getAppInfo($app); $version = OC_Util::getVersion(); if (!isset($info['require']) or !self::isAppVersionCompatible($version, $info['require'])) { throw new \Exception($l->t("App \"%s\" can't be installed because it is not compatible with this version of ownCloud.", array($info['name']))); } else { OC_Appconfig::setValue($app, 'enabled', 'yes'); if (isset($appdata['id'])) { OC_Appconfig::setValue($app, 'ocsid', $appdata['id']); } \OC_Hook::emit('OC_App', 'post_enable', array('app' => $app)); } } else { throw new \Exception($l->t("No app name specified")); } }
/** * @brief enables an app * @param mixed $app app * @return bool * * This function set an app as enabled in appconfig. */ public static function enable($app) { if (!OC_Installer::isInstalled($app)) { // check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string if (!is_numeric($app)) { $app = OC_Installer::installShippedApp($app); } else { $download = OC_OCSClient::getApplicationDownload($app, 1); if (isset($download['downloadlink']) and $download['downloadlink'] != '') { $app = OC_Installer::installApp(array('source' => 'http', 'href' => $download['downloadlink'])); } } } if ($app !== false) { // check if the app is compatible with this version of ownCloud $info = OC_App::getAppInfo($app); $version = OC_Util::getVersion(); if (!isset($info['require']) or $version[0] > $info['require']) { OC_Log::write('core', 'App "' . $info['name'] . '" can\'t be installed because it is not compatible with this version of ownCloud', OC_Log::ERROR); return false; } else { OC_Appconfig::setValue($app, 'enabled', 'yes'); return true; } } else { return false; } }