Skip to content

Commit 4cac49c

Browse files
committed
refresh cached app folder on install/upgrade
Signed-off-by: Maxence Lange <[email protected]>
1 parent 0c5eba3 commit 4cac49c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/private/legacy/OC_App.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,16 +477,17 @@ public static function getInstallPath() {
477477
* search for an app in all app-directories
478478
*
479479
* @param string $appId
480+
* @param bool $ignoreCache ignore cache and rebuild it
480481
* @return false|string
481482
*/
482-
public static function findAppInDirectories(string $appId) {
483+
public static function findAppInDirectories(string $appId, bool $ignoreCache = false) {
483484
$sanitizedAppId = self::cleanAppId($appId);
484485
if ($sanitizedAppId !== $appId) {
485486
return false;
486487
}
487488
static $app_dir = [];
488489

489-
if (isset($app_dir[$appId])) {
490+
if (isset($app_dir[$appId]) && !$ignoreCache) {
490491
return $app_dir[$appId];
491492
}
492493

@@ -527,15 +528,16 @@ public static function findAppInDirectories(string $appId) {
527528
* @psalm-taint-specialize
528529
*
529530
* @param string $appId
531+
* @param bool $refreshAppPath should be set to true only during install/upgrade
530532
* @return string|false
531533
* @deprecated 11.0.0 use \OC::$server->getAppManager()->getAppPath()
532534
*/
533-
public static function getAppPath(string $appId) {
535+
public static function getAppPath(string $appId, bool $refreshAppPath = false) {
534536
if ($appId === null || trim($appId) === '') {
535537
return false;
536538
}
537539

538-
if (($dir = self::findAppInDirectories($appId)) != false) {
540+
if (($dir = self::findAppInDirectories($appId, $refreshAppPath)) != false) {
539541
return $dir['path'] . '/' . $appId;
540542
}
541543
return false;
@@ -973,7 +975,9 @@ public static function getAppVersions() {
973975
* @return bool
974976
*/
975977
public static function updateApp(string $appId): bool {
976-
$appPath = self::getAppPath($appId);
978+
// for apps distributed with core, we refresh app path in case the downloaded version
979+
// have been installed in custom apps and not in the default path
980+
$appPath = self::getAppPath($appId, true);
977981
if ($appPath === false) {
978982
return false;
979983
}

0 commit comments

Comments
 (0)