Merge pull request #2594 from nextcloud/dont-use-cached-info

Don't use cached informations for app version when installing the app
This commit is contained in:
Roeland Jago Douma 2016-12-09 22:43:21 +01:00 committed by GitHub
commit 4f3f799e06
3 changed files with 12 additions and 5 deletions

View File

@ -121,7 +121,7 @@ class Installer {
OC_App::executeRepairSteps($appId, $appData['repair-steps']['install']); OC_App::executeRepairSteps($appId, $appData['repair-steps']['install']);
//set the installed version //set the installed version
\OC::$server->getConfig()->setAppValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id'])); \OC::$server->getConfig()->setAppValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id'], false));
\OC::$server->getConfig()->setAppValue($info['id'], 'enabled', 'no'); \OC::$server->getConfig()->setAppValue($info['id'], 'enabled', 'no');
//set remote/public handlers //set remote/public handlers

View File

@ -653,13 +653,16 @@ class OC_App {
* get the last version of the app from appinfo/info.xml * get the last version of the app from appinfo/info.xml
* *
* @param string $appId * @param string $appId
* @param bool $useCache
* @return string * @return string
*/ */
public static function getAppVersion($appId) { public static function getAppVersion($appId, $useCache = true) {
if (!isset(self::$appVersion[$appId])) { if($useCache && isset(self::$appVersion[$appId])) {
return self::$appVersion[$appId];
}
$file = self::getAppPath($appId); $file = self::getAppPath($appId);
self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0'; self::$appVersion[$appId] = ($file !== false) ? self::getAppVersionByPath($file) : '0';
}
return self::$appVersion[$appId]; return self::$appVersion[$appId];
} }

View File

@ -73,6 +73,9 @@ class InstallerTest extends TestCase {
} }
public function testInstallApp() { public function testInstallApp() {
// Read the current version of the app to check for bug #2572
\OC_App::getAppVersion('testapp');
// Extract app // Extract app
$pathOfTestApp = __DIR__ . '/../data/testapp.zip'; $pathOfTestApp = __DIR__ . '/../data/testapp.zip';
$tar = new ZIP($pathOfTestApp); $tar = new ZIP($pathOfTestApp);
@ -88,6 +91,7 @@ class InstallerTest extends TestCase {
$installer->installApp(self::$appid); $installer->installApp(self::$appid);
$isInstalled = Installer::isInstalled(self::$appid); $isInstalled = Installer::isInstalled(self::$appid);
$this->assertTrue($isInstalled); $this->assertTrue($isInstalled);
$this->assertSame('0.9', \OC::$server->getConfig()->getAppValue('testapp', 'installed_version'));
$installer->removeApp(self::$appid); $installer->removeApp(self::$appid);
} }