summaryrefslogtreecommitdiffstats
path: root/lib/connector/sabre/directory.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-06-15 17:51:56 +0200
committerBart Visscher <bartv@thisnet.nl>2012-06-15 21:21:42 +0200
commite11c5a23d52ba0bfe082f36311a504c72278aa40 (patch)
treeb8ade50e0fefe23931e1a9582f1c60a00da88f92 /lib/connector/sabre/directory.php
parente905b14758d18c5254ecf2fbe8e867ea96293877 (diff)
downloadnextcloud-server-e11c5a23d52ba0bfe082f36311a504c72278aa40.tar.gz
nextcloud-server-e11c5a23d52ba0bfe082f36311a504c72278aa40.zip
Optimize WebDav access by preloading dav custom properties
Diffstat (limited to 'lib/connector/sabre/directory.php')
-rw-r--r--lib/connector/sabre/directory.php22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index 6af4dd36562..9832449af3a 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -85,10 +85,28 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function getChildren() {
- $nodes = array();
$folder_content = OC_FileCache::getFolderContent($this->path);
+ $paths = array();
+ foreach($folder_content as $info) {
+ $paths[] = $this->path.'/'.$info['name'];
+ }
+ $placeholders = join(',', array_fill(0, count($paths), '?'));
+ $query = OC_DB::prepare( 'SELECT * FROM *PREFIX*properties WHERE userid = ?' . ' AND propertypath IN ('.$placeholders.')' );
+ array_unshift($paths, OC_User::getUser()); // prepend userid
+ $result = $query->execute( $paths );
+ $properties = array_fill_keys($paths, array());
+ while($row = $result->fetchRow()) {
+ $propertypath = $row['propertypath'];
+ $propertyname = $row['propertyname'];
+ $propertyvalue = $row['propertyvalue'];
+ $properties[$propertypath][$propertyname] = $propertyvalue;
+ }
+
+ $nodes = array();
foreach($folder_content as $info) {
- $nodes[] = $this->getChild($info['name'], $info);
+ $node = $this->getChild($info['name'], $info);
+ $node->setPropertyCache($properties[$this->path.'/'.$info['name']]);
+ $nodes[] = $node;
}
return $nodes;
}