77 *
88 * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
99 * @author Christoph Wurst <christoph@winzerhof-wurst.at>
10+ * @author Jonas Meurer <jonas@freesources.org>
1011 *
1112 * @license GNU AGPL version 3 or any later version
1213 *
3132use OCP \EventDispatcher \GenericEvent ;
3233use OCP \Files \InvalidPathException ;
3334use OCP \Files \IRootFolder ;
35+ use OCP \Files \Mount \IMountManager ;
3436use OCP \Files \Node ;
3537use OCP \Files \NotFoundException ;
3638use OCP \IL10N ;
@@ -74,6 +76,8 @@ class File implements IEntity, IDisplayText, IUrl, IIcon, IContextPortation {
7476 private $ userManager ;
7577 /** @var UserMountCache */
7678 private $ userMountCache ;
79+ /** @var IMountManager */
80+ private $ mountManager ;
7781
7882 public function __construct (
7983 IL10N $ l10n ,
@@ -82,7 +86,8 @@ public function __construct(
8286 IUserSession $ userSession ,
8387 ISystemTagManager $ tagManager ,
8488 IUserManager $ userManager ,
85- UserMountCache $ userMountCache
89+ UserMountCache $ userMountCache ,
90+ IMountManager $ mountManager
8691 ) {
8792 $ this ->l10n = $ l10n ;
8893 $ this ->urlGenerator = $ urlGenerator ;
@@ -91,6 +96,7 @@ public function __construct(
9196 $ this ->tagManager = $ tagManager ;
9297 $ this ->userManager = $ userManager ;
9398 $ this ->userMountCache = $ userMountCache ;
99+ $ this ->mountManager = $ mountManager ;
94100 }
95101
96102 public function getName (): string {
@@ -143,10 +149,10 @@ public function isLegitimatedForUserId(string $uid): bool {
143149 $ fileId = $ node ->getId ();
144150 }
145151
146- $ mounts = $ this ->userMountCache ->getMountsForFileId ($ fileId , $ uid );
147- foreach ($ mounts as $ mount ) {
148- $ userFolder = $ this ->root -> getUserFolder ( $ uid );
149- if (!empty ($ userFolder -> getById ($ fileId ))) {
152+ $ mountInfos = $ this ->userMountCache ->getMountsForFileId ($ fileId , $ uid );
153+ foreach ($ mountInfos as $ mountInfo ) {
154+ $ mount = $ this ->mountManager -> getMountFromMountInfo ( $ mountInfo );
155+ if ($ mount && !empty ($ mount -> getStorage ()-> getCache ()-> get ($ fileId ))) {
150156 return true ;
151157 }
152158 }
0 commit comments