@@ -97,6 +97,7 @@ public function uploadFile(SettingsUrl $settingsUrl, string $fileData, string $u
97
97
$ fileName = $ settingsUrl ->getFileName ();
98
98
$ newFile = $ categoryFolder ->newFile ($ fileName , $ fileData );
99
99
$ fileUri = $ this ->generateFileUri ($ settingsUrl ->getType (), $ settingsUrl ->getCategory (), $ fileName , $ userId );
100
+ $ this ->refreshFolderEtag ($ settingsUrl ->getType ());
100
101
101
102
return [
102
103
'stamp ' => $ newFile ->getETag (),
@@ -154,6 +155,15 @@ public function generateIframeToken(string $type, string $userId): array {
154
155
throw $ e ;
155
156
}
156
157
}
158
+
159
+ /**
160
+ *
161
+ * @param string $type
162
+ * @return string
163
+ */
164
+ public function getFolderEtag ($ type ) : string {
165
+ return $ this ->getTypeFolder ($ type )->getEtag ();
166
+ }
157
167
158
168
/**
159
169
* generate setting config
@@ -210,12 +220,7 @@ private function getAllCategories(string $type): array {
210
220
*/
211
221
private function getCategoryDirFolderList (string $ type ) : array {
212
222
try {
213
- $ instanceId = $ this ->config ->getSystemValue ('instanceid ' , null );
214
- if ($ instanceId === null ) {
215
- throw new NotFoundException ('Instance ID not found ' );
216
- }
217
- $ rootFolder = $ this ->rootFolder ;
218
- $ folder = $ rootFolder ->get ('appdata_ ' . $ instanceId . '/richdocuments ' . '/ ' . $ type );
223
+ $ folder = $ this ->getTypeFolder ($ type );
219
224
if (!$ folder instanceof Folder) {
220
225
return [];
221
226
}
@@ -225,6 +230,36 @@ private function getCategoryDirFolderList(string $type) : array {
225
230
}
226
231
}
227
232
233
+ /**
234
+ * extract folder of $type
235
+ *
236
+ * @param string $type
237
+ * @return Folder
238
+ */
239
+ private function getTypeFolder ($ type ) {
240
+ $ instanceId = $ this ->config ->getSystemValue ('instanceid ' , null );
241
+ if ($ instanceId === null ) {
242
+ throw new NotFoundException ('Instance ID not found ' );
243
+ }
244
+ $ rootFolder = $ this ->rootFolder ;
245
+ try {
246
+ $ folder = $ rootFolder ->get ('appdata_ ' . $ instanceId . '/richdocuments ' . '/ ' . $ type );
247
+ } catch (NotFoundException $ e ) {
248
+ $ baseFolder = $ this ->appData ->newFolder ($ type );
249
+ $ folder = $ rootFolder ->get ('appdata_ ' . $ instanceId . '/richdocuments ' . '/ ' . $ type );
250
+ }
251
+ return $ folder ;
252
+ }
253
+
254
+ /**
255
+ *
256
+ * @param string $type
257
+ */
258
+ private function refreshFolderEtag ($ type ) {
259
+ $ folder = $ this ->getTypeFolder ($ type );
260
+ $ folder ->getStorage ()->getCache ()->update ($ folder ->getId (), [ 'etag ' => uniqid () ]);
261
+ }
262
+
228
263
/**
229
264
* Generate file URL.
230
265
*
@@ -314,6 +349,7 @@ public function deleteSettingsFile(string $type, string $category, string $name,
314
349
throw new NotFoundException ("File ' {$ name }' not found in category ' {$ category }' for type ' {$ type }'. " );
315
350
}
316
351
$ categoryFolder ->getFile ($ name )->delete ();
352
+ $ this ->refreshFolderEtag ($ type );
317
353
} catch (NotFoundException $ e ) {
318
354
throw $ e ;
319
355
} catch (NotPermittedException $ e ) {
0 commit comments