Skip to content

Commit 4a503f6

Browse files
andrey18106backportbot[bot]
authored andcommitted
fix(exAppArchiveFetcher): correct apps_paths handling
Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
1 parent 0b5b305 commit 4a503f6

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

lib/Fetcher/ExAppArchiveFetcher.php

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

9797
public function getExAppFolder(string $appId): ?string {
98-
$appsPaths = $this->config->getSystemValue('apps_paths');
98+
$appsPaths = $this->config->getSystemValue('apps_paths', []);
9999
$existingPath = '';
100100
foreach ($appsPaths as $appPath) {
101101
if ($appPath['writable'] && file_exists($appPath['path'] . '/' . $appId)) {
@@ -112,15 +112,27 @@ public function getExAppFolder(string $appId): ?string {
112112
}
113113
}
114114
}
115+
// Fallback to default ExApp folder
116+
$defaultExAppFolder = \OC::$SERVERROOT . '/apps/' . $appId;
117+
if (is_dir($defaultExAppFolder)) {
118+
return $defaultExAppFolder;
119+
}
115120
return null;
116121
}
117122

118123
public function removeExAppFolder(string $appId): void {
119-
foreach ($this->config->getSystemValue('apps_paths', []) as $appPath) {
120-
if ($appPath['writable']) {
121-
if (file_exists($appPath['path'] . '/' . $appId)) {
122-
$this->rmdirr($appPath['path'] . '/' . $appId);
123-
}
124+
$appsPaths = $this->config->getSystemValue('apps_paths', []);
125+
if (empty($appsPaths)) {
126+
// fallback check of default ExApp folder
127+
$defaultExAppFolder = \OC::$SERVERROOT . '/apps/' . $appId;
128+
if (is_dir($defaultExAppFolder)) {
129+
$this->rmdirr($defaultExAppFolder);
130+
}
131+
return;
132+
}
133+
foreach ($appsPaths as $appPath) {
134+
if ($appPath['writable'] && file_exists($appPath['path'] . '/' . $appId)) {
135+
$this->rmdirr($appPath['path'] . '/' . $appId);
124136
}
125137
}
126138
}

0 commit comments

Comments
 (0)