@@ -77,6 +77,8 @@ class FilesPlugin extends ServerPlugin {
7777 public const UPLOAD_TIME_PROPERTYNAME = '{http://nextcloud.org/ns}upload_time ' ;
7878 public const CREATION_TIME_PROPERTYNAME = '{http://nextcloud.org/ns}creation_time ' ;
7979 public const SHARE_NOTE = '{http://nextcloud.org/ns}note ' ;
80+ public const SUBFOLDER_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-folder-count ' ;
81+ public const SUBFILE_COUNT_PROPERTYNAME = '{http://nextcloud.org/ns}contained-file-count ' ;
8082
8183 /**
8284 * Reference to main server object
@@ -435,14 +437,31 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
435437 });
436438 }
437439
438- if ($ node instanceof \ OCA \ DAV \ Connector \ Sabre \ Directory) {
440+ if ($ node instanceof Directory) {
439441 $ propFind ->handle (self ::SIZE_PROPERTYNAME , function () use ($ node ) {
440442 return $ node ->getSize ();
441443 });
442444
443445 $ propFind ->handle (self ::IS_ENCRYPTED_PROPERTYNAME , function () use ($ node ) {
444446 return $ node ->getFileInfo ()->isEncrypted () ? '1 ' : '0 ' ;
445447 });
448+
449+ $ requestProperties = $ propFind ->getRequestedProperties ();
450+ if (in_array (self ::SUBFILE_COUNT_PROPERTYNAME , $ requestProperties , true )
451+ || in_array (self ::SUBFOLDER_COUNT_PROPERTYNAME , $ requestProperties , true )) {
452+ $ nbFiles = 0 ;
453+ $ nbFolders = 0 ;
454+ foreach ($ node ->getChildren () as $ child ) {
455+ if ($ child instanceof File) {
456+ $ nbFiles ++;
457+ } elseif ($ child instanceof Directory) {
458+ $ nbFolders ++;
459+ }
460+ }
461+
462+ $ propFind ->handle (self ::SUBFILE_COUNT_PROPERTYNAME , $ nbFiles );
463+ $ propFind ->handle (self ::SUBFOLDER_COUNT_PROPERTYNAME , $ nbFolders );
464+ }
446465 }
447466 }
448467
0 commit comments