aboutsummaryrefslogtreecommitdiffstats
path: root/lib/connector/sabre/directory.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/connector/sabre/directory.php')
-rw-r--r--lib/connector/sabre/directory.php49
1 files changed, 31 insertions, 18 deletions
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index e74d832cb00..9832449af3a 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -59,22 +59,23 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
* @throws Sabre_DAV_Exception_FileNotFound
* @return Sabre_DAV_INode
*/
- public function getChild($name) {
+ public function getChild($name, $info = null) {
$path = $this->path . '/' . $name;
+ if (is_null($info)) {
+ $info = OC_FileCache::get($path);
+ }
- if (!OC_Filesystem::file_exists($path)) throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
-
- if (OC_Filesystem::is_dir($path)) {
-
- return new OC_Connector_Sabre_Directory($path);
+ if (!$info) throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
+ if ($info['mimetype'] == 'httpd/unix-directory') {
+ $node = new OC_Connector_Sabre_Directory($path);
} else {
-
- return new OC_Connector_Sabre_File($path);
-
+ $node = new OC_Connector_Sabre_File($path);
}
+ $node->setFileinfoCache($info);
+ return $node;
}
/**
@@ -84,18 +85,30 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function getChildren() {
+ $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(scandir($this->path) as $node) if($node!='.' && $node!='..') $nodes[] = $this->getChild($node);
- if( OC_Filesystem::is_dir($this->path . '/')){
- $dh = OC_Filesystem::opendir($this->path . '/');
- while(( $node = readdir($dh)) !== false ){
- if($node!='.' && $node!='..'){
- $nodes[] = $this->getChild($node);
- }
- }
+ foreach($folder_content as $info) {
+ $node = $this->getChild($info['name'], $info);
+ $node->setPropertyCache($properties[$this->path.'/'.$info['name']]);
+ $nodes[] = $node;
}
return $nodes;
-
}
/**