Skip to content

Commit 403fa10

Browse files
committed
fix(exAppArchiveFetcher): correct apps_paths handling
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
1 parent dc041e0 commit 403fa10

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

lib/Fetcher/ExAppArchiveFetcher.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function installTranslations(string $appId, string $dirTranslations): str
9090
}
9191

9292
public function getExAppFolder(string $appId): ?string {
93-
$appsPaths = $this->config->getSystemValue('apps_paths');
93+
$appsPaths = $this->config->getSystemValue('apps_paths', []);
9494
$existingPath = '';
9595
foreach ($appsPaths as $appPath) {
9696
if ($appPath['writable'] && file_exists($appPath['path'] . '/' . $appId)) {
@@ -107,15 +107,27 @@ public function getExAppFolder(string $appId): ?string {
107107
}
108108
}
109109
}
110+
// Fallback to default ExApp folder
111+
$defaultExAppFolder = \OC::$SERVERROOT . '/apps/' . $appId;
112+
if (is_dir($defaultExAppFolder)) {
113+
return $defaultExAppFolder;
114+
}
110115
return null;
111116
}
112117

113118
public function removeExAppFolder(string $appId): void {
114-
foreach ($this->config->getSystemValue('apps_paths') as $appPath) {
115-
if ($appPath['writable']) {
116-
if (file_exists($appPath['path'] . '/' . $appId)) {
117-
$this->rmdirr($appPath['path'] . '/' . $appId);
118-
}
119+
$appsPaths = $this->config->getSystemValue('apps_paths', []);
120+
if (empty($appsPaths)) {
121+
// fallback check of default ExApp folder
122+
$defaultExAppFolder = \OC::$SERVERROOT . '/apps/' . $appId;
123+
if (is_dir($defaultExAppFolder)) {
124+
$this->rmdirr($defaultExAppFolder);
125+
}
126+
return;
127+
}
128+
foreach ($appsPaths as $appPath) {
129+
if ($appPath['writable'] && file_exists($appPath['path'] . '/' . $appId)) {
130+
$this->rmdirr($appPath['path'] . '/' . $appId);
119131
}
120132
}
121133
}

0 commit comments

Comments
 (0)