3030use OCP \AppFramework \Utility \ITimeFactory ;
3131use OCP \BackgroundJob \IJobList ;
3232use OCP \DB \Exception ;
33+ use OCP \Files \Config \ICachedMountInfo ;
3334use OCP \Files \Config \IUserMountCache ;
3435use OCP \Files \File ;
3536use OCP \Files \IRootFolder ;
@@ -96,7 +97,6 @@ public function getFileContents(IRootFolder $rootFolder, int $fileId, string $us
9697 #[ExAppRequired]
9798 #[ApiRoute(verb: 'GET ' , url: '/queues/documents/ ' )]
9899 public function getDocumentsQueueItems (
99- StorageService $ storageService ,
100100 IRootFolder $ rootFolder ,
101101 QueueMapper $ queueMapper ,
102102 QueueContentItemMapper $ queueContentItemMapper ,
@@ -122,7 +122,7 @@ public function getDocumentsQueueItems(
122122 foreach ($ documents as $ document ) {
123123 if ($ queueMapper ->lock ($ document ->getId ())) {
124124 try {
125- $ files [$ document ->getId ()] = $ this ->getFileSource ($ document , $ rootFolder , $ storageService , $ userMountCache );
125+ $ files [$ document ->getId ()] = $ this ->getFileSource ($ document , $ rootFolder , $ userMountCache );
126126 } catch (\Exception $ e ) {
127127 $ this ->logger ->warning ($ e ->getMessage (), ['exception ' => $ e ]);
128128 $ queueMapper ->delete ($ document );
@@ -285,18 +285,18 @@ public function countActionsQueueItems(QueueActionMapper $queueActionMapper) : D
285285 }
286286 }
287287
288- private function getFileSource (QueueFile $ document , IRootFolder $ rootFolder , StorageService $ storageService , IUserMountCache $ userMountCache ) : Source {
289- $ mounts = $ userMountCache ->getMountsForStorageId ($ document ->getStorageId ());
288+ private function getFileSource (QueueFile $ document , IRootFolder $ rootFolder , IUserMountCache $ userMountCache ) : Source {
289+ $ mounts = $ userMountCache ->getMountsForFileId ($ document ->getFileId ());
290290 if (empty ($ mounts )) {
291- throw new \Exception ('Couldn \'t find any mounts for this storage ' );
291+ throw new \Exception ('Couldn \'t find any mounts for this file ' );
292292 }
293+ $ userIds = array_map (static fn (ICachedMountInfo $ mount ) => $ mount ->getUser ()->getUID (), $ mounts );
293294 $ file = null ;
294- foreach ($ mounts as $ mount ) {
295- $ userId = $ mount ->getUser ()->getUID ();
295+ foreach ($ userIds as $ userId ) {
296296 try {
297297 $ file = $ rootFolder ->getUserFolder ($ userId )->getFirstNodeById ($ document ->getFileId ());
298298 } catch (NotPermittedException $ e ) {
299- throw new \ Exception ( ' Not allowed to get user folder ' ) ;
299+ continue ;
300300 }
301301 if ($ file instanceof File) {
302302 break ;
@@ -305,7 +305,6 @@ private function getFileSource(QueueFile $document, IRootFolder $rootFolder, Sto
305305 if (!($ file instanceof File)) {
306306 throw new \Exception ('File not found or not a file ' );
307307 }
308- $ userIds = $ storageService ->getUsersForFileId ($ document ->getFileId ());
309308
310309 return new Source (
311310 $ userIds ,
0 commit comments