@@ -56,35 +56,35 @@ class Node implements \OCP\Files\Node {
5656 */
5757 protected $ path ;
5858
59- /**
60- * @var \OCP\Files\FileInfo
61- */
62- protected $ fileInfo ;
59+ protected ?FileInfo $ fileInfo ;
6360
6461 /**
6562 * @var Node|null
6663 */
6764 protected $ parent ;
6865
66+ private bool $ infoHasSubMountsIncluded ;
67+
6968 /**
7069 * @param \OC\Files\View $view
7170 * @param \OCP\Files\IRootFolder $root
7271 * @param string $path
7372 * @param FileInfo $fileInfo
7473 */
75- public function __construct ($ root , $ view , $ path , $ fileInfo = null , ?Node $ parent = null ) {
74+ public function __construct ($ root , $ view , $ path , $ fileInfo = null , ?Node $ parent = null , bool $ infoHasSubMountsIncluded = true ) {
7675 $ this ->view = $ view ;
7776 $ this ->root = $ root ;
7877 $ this ->path = $ path ;
7978 $ this ->fileInfo = $ fileInfo ;
8079 $ this ->parent = $ parent ;
80+ $ this ->infoHasSubMountsIncluded = $ infoHasSubMountsIncluded ;
8181 }
8282
8383 /**
8484 * Creates a Node of the same type that represents a non-existing path
8585 *
8686 * @param string $path path
87- * @return string non-existing node class
87+ * @return Node non-existing node
8888 * @throws \Exception
8989 */
9090 protected function createNonExistingNode ($ path ) {
@@ -98,17 +98,23 @@ protected function createNonExistingNode($path) {
9898 * @throws InvalidPathException
9999 * @throws NotFoundException
100100 */
101- public function getFileInfo () {
101+ public function getFileInfo (bool $ includeMountPoint = true ) {
102102 if (!$ this ->fileInfo ) {
103103 if (!Filesystem::isValidPath ($ this ->path )) {
104104 throw new InvalidPathException ();
105105 }
106- $ fileInfo = $ this ->view ->getFileInfo ($ this ->path );
106+ $ fileInfo = $ this ->view ->getFileInfo ($ this ->path , $ includeMountPoint );
107+ $ this ->infoHasSubMountsIncluded = $ includeMountPoint ;
107108 if ($ fileInfo instanceof FileInfo) {
108109 $ this ->fileInfo = $ fileInfo ;
109110 } else {
110111 throw new NotFoundException ();
111112 }
113+ } elseif ($ includeMountPoint && !$ this ->infoHasSubMountsIncluded && $ this instanceof Folder) {
114+ if ($ this ->fileInfo instanceof \OC \Files \FileInfo) {
115+ $ this ->view ->addSubMounts ($ this ->fileInfo );
116+ }
117+ $ this ->infoHasSubMountsIncluded = true ;
112118 }
113119 return $ this ->fileInfo ;
114120 }
@@ -179,7 +185,7 @@ public function getPath() {
179185 * @return string
180186 */
181187 public function getInternalPath () {
182- return $ this ->getFileInfo ()->getInternalPath ();
188+ return $ this ->getFileInfo (false )->getInternalPath ();
183189 }
184190
185191 /**
@@ -188,7 +194,7 @@ public function getInternalPath() {
188194 * @throws NotFoundException
189195 */
190196 public function getId () {
191- return $ this ->getFileInfo ()->getId ();
197+ return $ this ->getFileInfo (false )->getId ();
192198 }
193199
194200 /**
@@ -232,7 +238,7 @@ public function getEtag() {
232238 * @throws NotFoundException
233239 */
234240 public function getPermissions () {
235- return $ this ->getFileInfo ()->getPermissions ();
241+ return $ this ->getFileInfo (false )->getPermissions ();
236242 }
237243
238244 /**
@@ -241,7 +247,7 @@ public function getPermissions() {
241247 * @throws NotFoundException
242248 */
243249 public function isReadable () {
244- return $ this ->getFileInfo ()->isReadable ();
250+ return $ this ->getFileInfo (false )->isReadable ();
245251 }
246252
247253 /**
@@ -250,7 +256,7 @@ public function isReadable() {
250256 * @throws NotFoundException
251257 */
252258 public function isUpdateable () {
253- return $ this ->getFileInfo ()->isUpdateable ();
259+ return $ this ->getFileInfo (false )->isUpdateable ();
254260 }
255261
256262 /**
@@ -259,7 +265,7 @@ public function isUpdateable() {
259265 * @throws NotFoundException
260266 */
261267 public function isDeletable () {
262- return $ this ->getFileInfo ()->isDeletable ();
268+ return $ this ->getFileInfo (false )->isDeletable ();
263269 }
264270
265271 /**
@@ -268,7 +274,7 @@ public function isDeletable() {
268274 * @throws NotFoundException
269275 */
270276 public function isShareable () {
271- return $ this ->getFileInfo ()->isShareable ();
277+ return $ this ->getFileInfo (false )->isShareable ();
272278 }
273279
274280 /**
@@ -277,7 +283,7 @@ public function isShareable() {
277283 * @throws NotFoundException
278284 */
279285 public function isCreatable () {
280- return $ this ->getFileInfo ()->isCreatable ();
286+ return $ this ->getFileInfo (false )->isCreatable ();
281287 }
282288
283289 /**
@@ -328,42 +334,42 @@ public function isValidPath($path) {
328334 }
329335
330336 public function isMounted () {
331- return $ this ->getFileInfo ()->isMounted ();
337+ return $ this ->getFileInfo (false )->isMounted ();
332338 }
333339
334340 public function isShared () {
335- return $ this ->getFileInfo ()->isShared ();
341+ return $ this ->getFileInfo (false )->isShared ();
336342 }
337343
338344 public function getMimeType () {
339- return $ this ->getFileInfo ()->getMimetype ();
345+ return $ this ->getFileInfo (false )->getMimetype ();
340346 }
341347
342348 public function getMimePart () {
343- return $ this ->getFileInfo ()->getMimePart ();
349+ return $ this ->getFileInfo (false )->getMimePart ();
344350 }
345351
346352 public function getType () {
347- return $ this ->getFileInfo ()->getType ();
353+ return $ this ->getFileInfo (false )->getType ();
348354 }
349355
350356 public function isEncrypted () {
351- return $ this ->getFileInfo ()->isEncrypted ();
357+ return $ this ->getFileInfo (false )->isEncrypted ();
352358 }
353359
354360 public function getMountPoint () {
355- return $ this ->getFileInfo ()->getMountPoint ();
361+ return $ this ->getFileInfo (false )->getMountPoint ();
356362 }
357363
358364 public function getOwner () {
359- return $ this ->getFileInfo ()->getOwner ();
365+ return $ this ->getFileInfo (false )->getOwner ();
360366 }
361367
362368 public function getChecksum () {
363369 }
364370
365371 public function getExtension (): string {
366- return $ this ->getFileInfo ()->getExtension ();
372+ return $ this ->getFileInfo (false )->getExtension ();
367373 }
368374
369375 /**
0 commit comments