@@ -209,20 +209,6 @@ function ($mountPoint, IStorage $storage, IMountPoint $mount) use ($reSharingEna
209209 return $ storage ;
210210 }, 50 , $ existingMounts );
211211
212- $ quotaIncludeExternal = $ this ->config ->getSystemValue ('quota_include_external_storage ' , false );
213- $ this ->storageFactory ->addStorageWrapper (Quota::class, function ($ mountPoint , $ storage , IMountPoint $ mount ) use ($ quotaIncludeExternal ) {
214- // set up quota for home storages, even for other users
215- // which can happen when using sharing
216- if ($ mount instanceof HomeMountPoint) {
217- $ user = $ mount ->getUser ();
218- return new Quota (['storage ' => $ storage , 'quotaCallback ' => function () use ($ user ) {
219- return $ user ->getQuotaBytes ();
220- }, 'root ' => 'files ' , 'include_external_storage ' => $ quotaIncludeExternal ]);
221- }
222-
223- return $ storage ;
224- }, 50 , $ existingMounts );
225-
226212 $ this ->storageFactory ->addStorageWrapper ('readonly ' , function (string $ mountPoint , IStorage $ storage , IMountPoint $ mount ) {
227213 /*
228214 * Do not allow any operations that modify the storage
@@ -241,6 +227,28 @@ function ($mountPoint, IStorage $storage, IMountPoint $mount) use ($reSharingEna
241227 }, 50 , $ existingMounts );
242228 }
243229
230+ /**
231+ * Some wrapper are inited after BeforeFileSystemSetupEvent, to permit
232+ * custom apps to preventively register their own handler
233+ *
234+ * @param IMountPoint[] $existingMounts
235+ */
236+ private function setupCustomizableWrappers (array $ existingMounts ): void {
237+ $ quotaIncludeExternal = $ this ->config ->getSystemValue ('quota_include_external_storage ' , false );
238+ $ this ->storageFactory ->addStorageWrapper (Quota::class, function ($ mountPoint , $ storage , IMountPoint $ mount ) use ($ quotaIncludeExternal ) {
239+ // set up quota for home storages, even for other users
240+ // which can happen when using sharing
241+ if ($ mount instanceof HomeMountPoint) {
242+ $ user = $ mount ->getUser ();
243+ return new Quota (['storage ' => $ storage , 'quotaCallback ' => function () use ($ user ) {
244+ return $ user ->getQuotaBytes ();
245+ }, 'root ' => 'files ' , 'include_external_storage ' => $ quotaIncludeExternal ]);
246+ }
247+
248+ return $ storage ;
249+ }, 50 , $ existingMounts );
250+ }
251+
244252 /**
245253 * Update the cached mounts for all non-authoritative mount providers for a user.
246254 */
@@ -328,6 +336,8 @@ private function oneTimeUserSetup(IUser $user): void {
328336 }
329337 }
330338
339+ $ this ->setupCustomizableWrappers ($ mounts );
340+
331341 $ userDir = '/ ' . $ user ->getUID () . '/files ' ;
332342
333343 Filesystem::initInternal ($ userDir );
0 commit comments