Skip to content

Commit

Permalink
fix(settings): fetch directory from root folder
Browse files Browse the repository at this point in the history
Signed-off-by: codewithvk <[email protected]>
  • Loading branch information
codewithvk committed Jan 27, 2025
1 parent 235882e commit 5302259
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions lib/Service/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

namespace OCA\Richdocuments\Service;

use OC\Files\Node\Folder;
use OCA\Richdocuments\AppInfo\Application;
use OCA\Richdocuments\Db\WopiMapper;
use OCA\Richdocuments\WOPI\SettingsUrl;
use OCP\Files\IAppData;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\Files\SimpleFS\ISimpleFile;
Expand Down Expand Up @@ -41,6 +43,7 @@ public function __construct(
private CapabilitiesService $capabilitiesService,
private WopiMapper $wopiMapper,
private IGroupManager $groupManager,
private IRootFolder $rootFolder,
) {
// Create a distributed cache for caching file lists
$this->cache = $cacheFactory->createDistributed(Application::APPNAME);
Expand Down Expand Up @@ -178,10 +181,9 @@ public function generateSettingsConfig(string $type): array {
private function getAllCategories(string $type): array {
try {
$categories = [];
$folder = $this->appData->getFolder($type);
$directories = $folder->getFullDirectoryListing();
$directories = $this->getCategoryDirFolderList($type);
foreach ($directories as $dir) {
if ($dir instanceof ISimpleFolder) {
if ($dir instanceof Folder) {
$categories[] = $dir->getName();
}
}
Expand All @@ -191,6 +193,25 @@ private function getAllCategories(string $type): array {
}
}

/**
*
* @param string $type
* @return Folder[]
*/
private function getCategoryDirFolderList(string $type) : array {
try {
$instanceId = $this->config->getSystemValue('instanceid', null);
if ($instanceId === null) {
throw new NotFoundException('Instance ID not found');
}
$rootFolder = $this->rootFolder;
$folder = $rootFolder->get('appdata_' . $instanceId . '/richdocuments' . '/' . $type);
return $folder->getDirectoryListing();

Check failure on line 209 in lib/Service/SettingsService.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedInterfaceMethod

lib/Service/SettingsService.php:209:20: UndefinedInterfaceMethod: Method OCP\Files\Node::getDirectoryListing does not exist (see https://psalm.dev/181)
} catch (NotFoundException $e) {
return [];
}
}

/**
* Generate file URL.
*
Expand Down

0 comments on commit 5302259

Please sign in to comment.