2323use OCP \Files \Events \FolderScannedEvent ;
2424use OCP \Files \Events \NodeAddedToCache ;
2525use OCP \Files \Events \NodeRemovedFromCache ;
26+ use OCP \Files \Mount \IMountPoint ;
2627use OCP \Files \NotFoundException ;
2728use OCP \Files \Storage \IStorage ;
2829use OCP \Files \StorageNotAvailableException ;
@@ -85,7 +86,7 @@ public function __construct($user, $db, IEventDispatcher $dispatcher, LoggerInte
8586 * get all storages for $dir
8687 *
8788 * @param string $dir
88- * @return \OC\Files\Mount\MountPoint[]
89+ * @return array<string, IMountPoint>
8990 */
9091 protected function getMounts ($ dir ) {
9192 //TODO: move to the node based fileapi once that's done
@@ -96,8 +97,9 @@ protected function getMounts($dir) {
9697 $ mounts = $ mountManager ->findIn ($ dir );
9798 $ mounts [] = $ mountManager ->find ($ dir );
9899 $ mounts = array_reverse ($ mounts ); //start with the mount of $dir
100+ $ mountPoints = array_map (fn ($ mount ) => $ mount ->getMountPoint (), $ mounts );
99101
100- return $ mounts ;
102+ return array_combine ( $ mountPoints , $ mounts) ;
101103 }
102104
103105 /**
@@ -210,6 +212,9 @@ public function scan($dir = '', $recursive = \OC\Files\Cache\Scanner::SCAN_RECUR
210212 $ owner = $ owner ['name ' ] ?? $ ownerUid ;
211213 $ permissions = decoct (fileperms ($ fullPath ));
212214 throw new ForbiddenException ("User folder $ fullPath is not writable, folders is owned by $ owner and has mode $ permissions " );
215+ } elseif (isset ($ mounts [$ mount ->getMountPoint () . $ path . '/ ' ])) {
216+ // /<user>/files is overwritten by a mountpoint, so this check is irrelevant
217+ break ;
213218 } else {
214219 // if the root exists in neither the cache nor the storage the user isn't setup yet
215220 break 2 ;
0 commit comments