@@ -50,13 +50,14 @@ public function __construct(
5050 * @param array|ICacheEntry|null $cacheEntry
5151 * @throws ForbiddenException
5252 */
53- public function checkFileAccess (IStorage $ storage , string $ path , IMountPoint $ mountPoint , bool $ isDir , $ cacheEntry = null ): void {
54- if (!$ this ->isBlockablePath ($ storage , $ path ) || $ this ->isCreatingSkeletonFiles () || $ this ->nestingLevel !== 0 ) {
53+ public function checkFileAccess (string $ path , IMountPoint $ mountPoint , bool $ isDir , $ cacheEntry = null ): void {
54+ if (!$ this ->isBlockablePath ($ mountPoint , $ path ) || $ this ->isCreatingSkeletonFiles () || $ this ->nestingLevel !== 0 ) {
5555 // Allow creating skeletons and theming
5656 // https://github.com/nextcloud/files_accesscontrol/issues/5
5757 // https://github.com/nextcloud/files_accesscontrol/issues/12
5858 return ;
5959 }
60+ $ storage = $ mountPoint ->getStorage ();
6061
6162 $ this ->nestingLevel ++;
6263
@@ -80,24 +81,8 @@ public function checkFileAccess(IStorage $storage, string $path, IMountPoint $mo
8081 }
8182 }
8283
83- protected function isBlockablePath (IStorage $ storage , string $ path ): bool {
84- if (property_exists ($ storage , 'mountPoint ' )) {
85- $ hasMountPoint = $ storage instanceof StorageWrapper;
86- if (!$ hasMountPoint ) {
87- $ ref = new ReflectionClass ($ storage );
88- $ prop = $ ref ->getProperty ('mountPoint ' );
89- $ hasMountPoint = $ prop ->isPublic ();
90- }
91-
92- if ($ hasMountPoint ) {
93- /** @var StorageWrapper $storage */
94- $ fullPath = $ storage ->mountPoint . ltrim ($ path , '/ ' );
95- } else {
96- $ fullPath = $ path ;
97- }
98- } else {
99- $ fullPath = $ path ;
100- }
84+ protected function isBlockablePath (IMountPoint $ mountPoint , string $ path ): bool {
85+ $ fullPath = $ mountPoint ->getMountPoint () . ltrim ($ path , '/ ' );
10186
10287 if (substr_count ($ fullPath , '/ ' ) < 3 ) {
10388 return false ;
@@ -299,22 +284,20 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch
299284
300285 private function getNode (string $ path , IMountPoint $ mountPoint , ICacheEntry |array |null $ cacheEntry = null ): ?Node {
301286 $ fullPath = $ mountPoint ->getMountPoint () . $ path ;
302- if ($ cacheEntry ) {
303- // todo: LazyNode?
304- $ info = new FileInfo ($ fullPath , $ mountPoint ->getStorage (), $ path , $ cacheEntry , $ mountPoint );
305- $ isDir = $ info ->getType () === \OCP \Files \FileInfo::TYPE_FOLDER ;
306- $ view = new View ('' );
307- if ($ isDir ) {
308- return new Folder ($ this ->rootFolder , $ view , $ path , $ info );
309- } else {
310- return new \OC \Files \Node \File ($ this ->rootFolder , $ view , $ path , $ info );
311- }
312- } else {
313- try {
314- return $ this ->rootFolder ->get ($ fullPath );
315- } catch (NotFoundException ) {
316- return null ;
317- }
287+ if (!$ cacheEntry ) {
288+ $ cacheEntry = $ mountPoint ->getStorage ()->getCache ()->get ($ path );
289+ }
290+ if (!$ cacheEntry ) {
291+ return null ;
292+ }
293+
294+ // todo: LazyNode?
295+ $ info = new FileInfo ($ fullPath , $ mountPoint ->getStorage (), $ path , $ cacheEntry , $ mountPoint );
296+ $ isDir = $ info ->getType () === FileInfo::TYPE_FOLDER ;
297+ $ view = new View ('' );
298+ if ($ isDir ) {
299+ return new Folder ($ this ->rootFolder , $ view , $ path , $ info );
318300 }
301+ return new \OC \Files \Node \File ($ this ->rootFolder , $ view , $ path , $ info );
319302 }
320303}
0 commit comments