Skip to content

Commit 9322917

Browse files
author
Julien Veyssier
committed
add optional WebDav propfind properties to show number of folders/files inside a folder
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
1 parent 9026455 commit 9322917

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

apps/dav/lib/Connector/Sabre/FilesPlugin.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class FilesPlugin extends ServerPlugin {
6363
public const OCM_SHARE_PERMISSIONS_PROPERTYNAME = '{http://open-cloud-mesh.org/ns}share-permissions';
6464
public const DOWNLOADURL_PROPERTYNAME = '{http://owncloud.org/ns}downloadURL';
6565
public const SIZE_PROPERTYNAME = '{http://owncloud.org/ns}size';
66+
public const SUBFOLDER_COUNT_PROPERTYNAME = '{http://owncloud.org/ns}subfolders';
67+
public const SUBFILE_COUNT_PROPERTYNAME = '{http://owncloud.org/ns}subfiles';
6668
public const GETETAG_PROPERTYNAME = '{DAV:}getetag';
6769
public const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified';
6870
public const CREATIONDATE_PROPERTYNAME = '{DAV:}creationdate';
@@ -443,6 +445,25 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
443445
$propFind->handle(self::IS_ENCRYPTED_PROPERTYNAME, function () use ($node) {
444446
return $node->getFileInfo()->isEncrypted() ? '1' : '0';
445447
});
448+
449+
$propFind->handle(self::SUBFOLDER_COUNT_PROPERTYNAME, function () use ($node) {
450+
$nbFolders = 0;
451+
foreach ($node->getChildren() as $child) {
452+
if ($child instanceof Directory) {
453+
$nbFolders++;
454+
}
455+
}
456+
return $nbFolders;
457+
});
458+
$propFind->handle(self::SUBFILE_COUNT_PROPERTYNAME, function () use ($node) {
459+
$nbFiles = 0;
460+
foreach ($node->getChildren() as $child) {
461+
if ($child instanceof File) {
462+
$nbFiles++;
463+
}
464+
}
465+
return $nbFiles;
466+
});
446467
}
447468
}
448469

0 commit comments

Comments
 (0)