From 3e687e01ae420c59d5391a9337f5bd8dfef51c95 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Tue, 5 Aug 2025 23:18:04 +0300 Subject: [PATCH 1/2] fix(exAppArchiveFetcher): correct apps_paths handling Signed-off-by: Andrey Borysenko --- lib/Fetcher/ExAppArchiveFetcher.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/Fetcher/ExAppArchiveFetcher.php b/lib/Fetcher/ExAppArchiveFetcher.php index 73f89bc1..29ef1711 100644 --- a/lib/Fetcher/ExAppArchiveFetcher.php +++ b/lib/Fetcher/ExAppArchiveFetcher.php @@ -95,7 +95,7 @@ public function installTranslations(string $appId, string $dirTranslations): str } public function getExAppFolder(string $appId): ?string { - $appsPaths = $this->config->getSystemValue('apps_paths'); + $appsPaths = $this->config->getSystemValue('apps_paths', []); $existingPath = ''; foreach ($appsPaths as $appPath) { if ($appPath['writable'] && file_exists($appPath['path'] . '/' . $appId)) { @@ -112,15 +112,27 @@ public function getExAppFolder(string $appId): ?string { } } } + // Fallback to default ExApp folder + $defaultExAppFolder = \OC::$SERVERROOT . '/apps/' . $appId; + if (is_dir($defaultExAppFolder)) { + return $defaultExAppFolder; + } return null; } public function removeExAppFolder(string $appId): void { - foreach ($this->config->getSystemValue('apps_paths', []) as $appPath) { - if ($appPath['writable']) { - if (file_exists($appPath['path'] . '/' . $appId)) { - $this->rmdirr($appPath['path'] . '/' . $appId); - } + $appsPaths = $this->config->getSystemValue('apps_paths', []); + if (empty($appsPaths)) { + // fallback check of default ExApp folder + $defaultExAppFolder = \OC::$SERVERROOT . '/apps/' . $appId; + if (is_dir($defaultExAppFolder)) { + $this->rmdirr($defaultExAppFolder); + } + return; + } + foreach ($appsPaths as $appPath) { + if ($appPath['writable'] && file_exists($appPath['path'] . '/' . $appId)) { + $this->rmdirr($appPath['path'] . '/' . $appId); } } } From c74bdd68ad121dc2446a9b62828a302df841ba60 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Fri, 12 Sep 2025 12:08:08 +0530 Subject: [PATCH 2/2] address review comments Signed-off-by: Anupam Kumar --- lib/Fetcher/ExAppArchiveFetcher.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/Fetcher/ExAppArchiveFetcher.php b/lib/Fetcher/ExAppArchiveFetcher.php index 29ef1711..978b12b3 100644 --- a/lib/Fetcher/ExAppArchiveFetcher.php +++ b/lib/Fetcher/ExAppArchiveFetcher.php @@ -96,19 +96,11 @@ public function installTranslations(string $appId, string $dirTranslations): str public function getExAppFolder(string $appId): ?string { $appsPaths = $this->config->getSystemValue('apps_paths', []); - $existingPath = ''; - foreach ($appsPaths as $appPath) { - if ($appPath['writable'] && file_exists($appPath['path'] . '/' . $appId)) { - $existingPath = $appPath['path'] . '/' . $appId; - } - } - if (!empty($existingPath)) { - return $existingPath; - } foreach ($appsPaths as $appPath) { if ($appPath['writable']) { - if (mkdir($appPath['path'] . '/' . $appId)) { - return $appPath['path'] . '/' . $appId; + $fullAppPath = $appPath['path'] . '/' . $appId; + if (is_dir($fullAppPath) || mkdir($fullAppPath)) { + return $fullAppPath; } } } @@ -131,7 +123,7 @@ public function removeExAppFolder(string $appId): void { return; } foreach ($appsPaths as $appPath) { - if ($appPath['writable'] && file_exists($appPath['path'] . '/' . $appId)) { + if ($appPath['writable'] && is_dir($appPath['path'] . '/' . $appId)) { $this->rmdirr($appPath['path'] . '/' . $appId); } }