]> source.dussan.org Git - nextcloud-server.git/commitdiff
refresh cached app folder on install/upgrade 36257/head
authorMaxence Lange <maxence@artificial-owl.com>
Thu, 26 Jan 2023 11:38:20 +0000 (10:38 -0100)
committerMaxence Lange <maxence@artificial-owl.com>
Wed, 1 Feb 2023 12:07:31 +0000 (11:07 -0100)
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
lib/private/legacy/OC_App.php

index c7433d7c6c84b19f68ffdd929bc94a46bbe1d00c..c4c2f08976740660f0ec4153b673fe19183352b5 100644 (file)
@@ -477,16 +477,17 @@ class OC_App {
         * 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];
                }
 
@@ -527,15 +528,16 @@ class OC_App {
         * @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;
@@ -973,7 +975,9 @@ class OC_App {
         * @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;
                }