Skip to content

Commit 5302259

Browse files
committed
fix(settings): fetch directory from root folder
Signed-off-by: codewithvk <[email protected]>
1 parent 235882e commit 5302259

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

lib/Service/SettingsService.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88

99
namespace OCA\Richdocuments\Service;
1010

11+
use OC\Files\Node\Folder;
1112
use OCA\Richdocuments\AppInfo\Application;
1213
use OCA\Richdocuments\Db\WopiMapper;
1314
use OCA\Richdocuments\WOPI\SettingsUrl;
1415
use OCP\Files\IAppData;
16+
use OCP\Files\IRootFolder;
1517
use OCP\Files\NotFoundException;
1618
use OCP\Files\NotPermittedException;
1719
use OCP\Files\SimpleFS\ISimpleFile;
@@ -41,6 +43,7 @@ public function __construct(
4143
private CapabilitiesService $capabilitiesService,
4244
private WopiMapper $wopiMapper,
4345
private IGroupManager $groupManager,
46+
private IRootFolder $rootFolder,
4447
) {
4548
// Create a distributed cache for caching file lists
4649
$this->cache = $cacheFactory->createDistributed(Application::APPNAME);
@@ -178,10 +181,9 @@ public function generateSettingsConfig(string $type): array {
178181
private function getAllCategories(string $type): array {
179182
try {
180183
$categories = [];
181-
$folder = $this->appData->getFolder($type);
182-
$directories = $folder->getFullDirectoryListing();
184+
$directories = $this->getCategoryDirFolderList($type);
183185
foreach ($directories as $dir) {
184-
if ($dir instanceof ISimpleFolder) {
186+
if ($dir instanceof Folder) {
185187
$categories[] = $dir->getName();
186188
}
187189
}
@@ -191,6 +193,25 @@ private function getAllCategories(string $type): array {
191193
}
192194
}
193195

196+
/**
197+
*
198+
* @param string $type
199+
* @return Folder[]
200+
*/
201+
private function getCategoryDirFolderList(string $type) : array {
202+
try {
203+
$instanceId = $this->config->getSystemValue('instanceid', null);
204+
if ($instanceId === null) {
205+
throw new NotFoundException('Instance ID not found');
206+
}
207+
$rootFolder = $this->rootFolder;
208+
$folder = $rootFolder->get('appdata_' . $instanceId . '/richdocuments' . '/' . $type);
209+
return $folder->getDirectoryListing();
210+
} catch (NotFoundException $e) {
211+
return [];
212+
}
213+
}
214+
194215
/**
195216
* Generate file URL.
196217
*

0 commit comments

Comments
 (0)