From e155f28f5ec4226c015e311e61fcc21710f091f7 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 3 Mar 2016 18:37:48 +0100 Subject: [PATCH] Revert "No longer evaluate appinfo/version" --- lib/private/app.php | 11 ++++++++--- lib/private/app/appmanager.php | 3 +++ lib/private/installer.php | 9 +++++++-- lib/public/app.php | 2 +- tests/data/testapp.zip | Bin 689 -> 895 bytes tests/data/testapp2.zip | Bin 2240 -> 2449 bytes 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/private/app.php b/lib/private/app.php index 3b8cbba3898..7917c1c0c01 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -567,7 +567,7 @@ class OC_App { } /** - * get the last version of the app from appinfo/info.xml + * get the last version of the app, either from appinfo/version or from appinfo/info.xml * * @param string $appId * @return string @@ -587,9 +587,14 @@ class OC_App { * @return string */ public static function getAppVersionByPath($path) { + $versionFile = $path . '/appinfo/version'; $infoFile = $path . '/appinfo/info.xml'; - $appData = self::getAppInfo($infoFile, true); - return isset($appData['version']) ? $appData['version'] : ''; + if (is_file($versionFile)) { + return trim(file_get_contents($versionFile)); + } else { + $appData = self::getAppInfo($infoFile, true); + return isset($appData['version']) ? $appData['version'] : ''; + } } diff --git a/lib/private/app/appmanager.php b/lib/private/app/appmanager.php index 69e5334774e..fba5bb19f61 100644 --- a/lib/private/app/appmanager.php +++ b/lib/private/app/appmanager.php @@ -299,6 +299,9 @@ class AppManager implements IAppManager { /** * Returns the app information from "appinfo/info.xml". * + * If no version was present in "appinfo/info.xml", reads it + * from the external "appinfo/version" file instead. + * * @param string $appId app id * * @return array app iinfo diff --git a/lib/private/installer.php b/lib/private/installer.php index 36fda28cd27..64f84d58b54 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -389,11 +389,16 @@ class OC_Installer{ } // check if the ocs version is the same as the version in info.xml/version - $version = trim($info['version']); + $versionFile= $extractDir.'/appinfo/version'; + if(is_file($versionFile)) { + $version = trim(file_get_contents($versionFile)); + }else{ + $version = trim($info['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 is not the same as the version reported from the app store")); + 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")); } return $info; diff --git a/lib/public/app.php b/lib/public/app.php index 032116eb43f..e25f025d12d 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -142,7 +142,7 @@ class App { } /** - * Get the last version of the app from appinfo/info.xml + * Get the last version of the app, either from appinfo/version or from appinfo/info.xml * @param string $app * @return string * @since 4.0.0 diff --git a/tests/data/testapp.zip b/tests/data/testapp.zip index c828572827f4ca1016cd5a859196586ee7f90287..e76c0d187248193e90ad487fbd172af065695aa3 100644 GIT binary patch delta 422 zcmdnU`k!sWJ~0LkAmpt*;=+IgBqjz5*JtLXe)L_&EgO3b=Ez9TexoAXIjO( z;jq)r84`}0g&&=Ds#v?`x5LIJ+0@w<({3rr>;7F_WU^T`pR<4YX~~jep&486I6GbN z4Vm&{W0BIG#=M{m=`OCv8`%FEbA2g)FFpAs<3kmDW)bX;1v(f46dESKW0DgK@MdKL R39ta6G9v>+1rReZ006-iT4n$M diff --git a/tests/data/testapp2.zip b/tests/data/testapp2.zip index 1953cc896f84dd3ddc6f1b837c08a9bdba15314e..f46832f7a757b2199f293ab05d16c368f55b3e8e 100644 GIT binary patch delta 455 zcmX>gI8k`A49nh$)?yo_9x*aYFbGVZ$RSxD8o|TxT(Lj+6cB%96k+h~+sJpwfX5~M zlW3@Y!-a*j3y&T-bl?EL%Syp%w^S@Lk3PT76_T{Ox_ld7+j$#PZO>;C=W@$!wlYgS z_|TKVcR*R})X}9ZVOu9XNITTNY1yGH(f%oW3$%VMjjOp_ziMfxEvtXU&U^U@<;xqR zPib?>H~r;wb$Z|0x`BPS_hRW+>v#ja**WTJ^}aVSFfeRo*!+OefpPLG7Lm#J%;Lhv zSBx1LKnhIr&Azh&6)-bwW?`0MWMO0yWuC0SBEiQ46a)i@AC3$RlQ*+FFqtt-{>tvb zRKhUXo{os;*lIx&8j{GZi}S)Y+%@_$CD$!Tn6Ol6Fd=dn4+AZ%w~kYGSE zv2ixju4U&DVPymPgc}IUm>C!#JOBiq Bj{N`t delta 371 zcmbOzd_ZvG2dRyhA2Dw3W>#UG%*pz1BGYaO5oQJk4u)-=ULMT;5kYMX3=C(1Sb|}) zH-}WcZ=WsSAp@S)^s25^>NzHK!v-rPH_+C>-_<%A9ZGF%$Z$tk$d*Pz}Q)q z0X!|sKYwL9H;eDjExDBn7Tir-w&8j$>;+;|XK8e)vs-8{dR@0qesTf3%;bM;e2ff} zdD)#9%_j%2doh*)Ns-A5m^mhIXE$Tq3*~W5UeCxm`39T7