Skip to content

Commit

Permalink
Merge pull request #36257 from nextcloud/fix/noid/single-upgrade-on-c…
Browse files Browse the repository at this point in the history
…ustom-apps

non-static app_dir
  • Loading branch information
szaimen authored Feb 1, 2023
2 parents 0c5eba3 + 4cac49c commit 41148ac
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/private/legacy/OC_App.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,16 +477,17 @@ public static function getInstallPath() {
* search for an app in all app-directories
*
* @param string $appId
* @param bool $ignoreCache ignore cache and rebuild it
* @return false|string
*/
public static function findAppInDirectories(string $appId) {
public static function findAppInDirectories(string $appId, bool $ignoreCache = false) {
$sanitizedAppId = self::cleanAppId($appId);
if ($sanitizedAppId !== $appId) {
return false;
}
static $app_dir = [];

if (isset($app_dir[$appId])) {
if (isset($app_dir[$appId]) && !$ignoreCache) {
return $app_dir[$appId];
}

Expand Down Expand Up @@ -527,15 +528,16 @@ public static function findAppInDirectories(string $appId) {
* @psalm-taint-specialize
*
* @param string $appId
* @param bool $refreshAppPath should be set to true only during install/upgrade
* @return string|false
* @deprecated 11.0.0 use \OC::$server->getAppManager()->getAppPath()
*/
public static function getAppPath(string $appId) {
public static function getAppPath(string $appId, bool $refreshAppPath = false) {
if ($appId === null || trim($appId) === '') {
return false;
}

if (($dir = self::findAppInDirectories($appId)) != false) {
if (($dir = self::findAppInDirectories($appId, $refreshAppPath)) != false) {
return $dir['path'] . '/' . $appId;
}
return false;
Expand Down Expand Up @@ -973,7 +975,9 @@ public static function getAppVersions() {
* @return bool
*/
public static function updateApp(string $appId): bool {
$appPath = self::getAppPath($appId);
// for apps distributed with core, we refresh app path in case the downloaded version
// have been installed in custom apps and not in the default path
$appPath = self::getAppPath($appId, true);
if ($appPath === false) {
return false;
}
Expand Down

0 comments on commit 41148ac

Please sign in to comment.