8
8
9
9
namespace OCA \Richdocuments \Service ;
10
10
11
+ use OC \Files \Node \Folder ;
11
12
use OCA \Richdocuments \AppInfo \Application ;
12
13
use OCA \Richdocuments \Db \WopiMapper ;
13
14
use OCA \Richdocuments \WOPI \SettingsUrl ;
14
15
use OCP \Files \IAppData ;
16
+ use OCP \Files \IRootFolder ;
15
17
use OCP \Files \NotFoundException ;
16
18
use OCP \Files \NotPermittedException ;
17
19
use OCP \Files \SimpleFS \ISimpleFile ;
@@ -41,6 +43,7 @@ public function __construct(
41
43
private CapabilitiesService $ capabilitiesService ,
42
44
private WopiMapper $ wopiMapper ,
43
45
private IGroupManager $ groupManager ,
46
+ private IRootFolder $ rootFolder ,
44
47
) {
45
48
// Create a distributed cache for caching file lists
46
49
$ this ->cache = $ cacheFactory ->createDistributed (Application::APPNAME );
@@ -178,10 +181,9 @@ public function generateSettingsConfig(string $type): array {
178
181
private function getAllCategories (string $ type ): array {
179
182
try {
180
183
$ categories = [];
181
- $ folder = $ this ->appData ->getFolder ($ type );
182
- $ directories = $ folder ->getFullDirectoryListing ();
184
+ $ directories = $ this ->getCategoryDirFolderList ($ type );
183
185
foreach ($ directories as $ dir ) {
184
- if ($ dir instanceof ISimpleFolder ) {
186
+ if ($ dir instanceof Folder ) {
185
187
$ categories [] = $ dir ->getName ();
186
188
}
187
189
}
@@ -191,6 +193,25 @@ private function getAllCategories(string $type): array {
191
193
}
192
194
}
193
195
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
+
194
215
/**
195
216
* Generate file URL.
196
217
*
0 commit comments