@@ -46,32 +46,34 @@ public function __construct(
4646 * @return IMountPoint[]
4747 */
4848 public function getMountsForUser (IUser $ user , IStorageFactory $ loader ) {
49+ $ userId = $ user ->getUID ();
4950 $ shares = array_merge (
50- $ this ->shareManager ->getSharedWith ($ user -> getUID () , IShare::TYPE_USER , null , -1 ),
51- $ this ->shareManager ->getSharedWith ($ user -> getUID () , IShare::TYPE_GROUP , null , -1 ),
52- $ this ->shareManager ->getSharedWith ($ user -> getUID () , IShare::TYPE_CIRCLE , null , -1 ),
53- $ this ->shareManager ->getSharedWith ($ user -> getUID () , IShare::TYPE_ROOM , null , -1 ),
54- $ this ->shareManager ->getSharedWith ($ user -> getUID () , IShare::TYPE_DECK , null , -1 ),
55- $ this ->shareManager ->getSharedWith ($ user -> getUID () , IShare::TYPE_SCIENCEMESH , null , -1 ),
51+ $ this ->shareManager ->getSharedWith ($ userId , IShare::TYPE_USER , null , -1 ),
52+ $ this ->shareManager ->getSharedWith ($ userId , IShare::TYPE_GROUP , null , -1 ),
53+ $ this ->shareManager ->getSharedWith ($ userId , IShare::TYPE_CIRCLE , null , -1 ),
54+ $ this ->shareManager ->getSharedWith ($ userId , IShare::TYPE_ROOM , null , -1 ),
55+ $ this ->shareManager ->getSharedWith ($ userId , IShare::TYPE_DECK , null , -1 ),
56+ $ this ->shareManager ->getSharedWith ($ userId , IShare::TYPE_SCIENCEMESH , null , -1 ),
5657 );
5758
58- // filter out excluded shares and group shares that includes self
59- $ shares = array_filter ($ shares , function (IShare $ share ) use ($ user ) {
60- return $ share ->getPermissions () > 0 && $ share ->getShareOwner () !== $ user ->getUID () && $ share ->getSharedBy () !== $ user ->getUID ();
59+ // filter out shares owned or shared by the user and ones for which
60+ // the user has no permissions
61+ $ shares = array_filter ($ shares , function (IShare $ share ) use ($ userId ) {
62+ return $ share ->getPermissions () > 0 && $ share ->getShareOwner () !== $ userId && $ share ->getSharedBy () !== $ userId ;
6163 });
6264
6365 $ superShares = $ this ->buildSuperShares ($ shares , $ user );
6466
6567 $ allMounts = $ this ->mountManager ->getAll ();
6668 $ mounts = [];
67- $ view = new View ('/ ' . $ user -> getUID () . '/files ' );
69+ $ view = new View ('/ ' . $ userId . '/files ' );
6870 $ ownerViews = [];
69- $ sharingDisabledForUser = $ this ->shareManager ->sharingDisabledForUser ($ user -> getUID () );
71+ $ sharingDisabledForUser = $ this ->shareManager ->sharingDisabledForUser ($ userId );
7072 /** @var CappedMemoryCache<bool> $folderExistCache */
7173 $ foldersExistCache = new CappedMemoryCache ();
7274
7375 $ validShareCache = $ this ->cacheFactory ->createLocal ('share-valid-mountpoint-max ' );
74- $ maxValidatedShare = $ validShareCache ->get ($ user -> getUID () ) ?? 0 ;
76+ $ maxValidatedShare = $ validShareCache ->get ($ userId ) ?? 0 ;
7577 $ newMaxValidatedShare = $ maxValidatedShare ;
7678
7779 foreach ($ superShares as $ share ) {
@@ -95,7 +97,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
9597 '\OCA\Files_Sharing\SharedStorage ' ,
9698 $ allMounts ,
9799 [
98- 'user ' => $ user -> getUID () ,
100+ 'user ' => $ userId ,
99101 // parent share
100102 'superShare ' => $ parentShare ,
101103 // children/component of the superShare
@@ -131,7 +133,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
131133 }
132134 }
133135
134- $ validShareCache ->set ($ user -> getUID () , $ newMaxValidatedShare , 24 * 60 * 60 );
136+ $ validShareCache ->set ($ userId , $ newMaxValidatedShare , 24 * 60 * 60 );
135137
136138 // array_filter removes the null values from the array
137139 return array_values (array_filter ($ mounts ));
@@ -148,10 +150,11 @@ private function groupShares(array $shares) {
148150 $ tmp = [];
149151
150152 foreach ($ shares as $ share ) {
151- if (!isset ($ tmp [$ share ->getNodeId ()])) {
152- $ tmp [$ share ->getNodeId ()] = [];
153+ $ nodeId = $ share ->getNodeId ();
154+ if (!isset ($ tmp [$ nodeId ])) {
155+ $ tmp [$ nodeId ] = [];
153156 }
154- $ tmp [$ share -> getNodeId () ][] = $ share ;
157+ $ tmp [$ nodeId ][] = $ share ;
155158 }
156159
157160 $ result = [];
0 commit comments