aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/js/fileactions.js2
-rw-r--r--lib/connector/sabre/directory.php25
-rw-r--r--lib/connector/sabre/file.php7
-rw-r--r--lib/connector/sabre/node.php22
4 files changed, 32 insertions, 24 deletions
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index deec640bc12..4dc05088eed 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -141,7 +141,7 @@ $(document).ready(function(){
var downloadScope = 'file';
}
FileActions.register(downloadScope,'Download',function(){return OC.imagePath('core','actions/download')},function(filename){
- window.location=OC.filePath('files', 'ajax', 'download.php') + '?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val());
+ window.location=OC.filePath('files', 'ajax', 'download.php') + encodeURIComponent('?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val()));
});
});
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index e74d832cb00..5aa70392d76 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -59,19 +59,22 @@ 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 (!$info) throw new Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
- if (OC_Filesystem::is_dir($path)) {
+ if ($info['mimetype'] == 'httpd/unix-directory') {
- return new OC_Connector_Sabre_Directory($path);
+ return new OC_Connector_Sabre_Directory($path, $info);
} else {
- return new OC_Connector_Sabre_File($path);
+ return new OC_Connector_Sabre_File($path, $info);
}
@@ -85,17 +88,11 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
public function getChildren() {
$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);
- }
- }
+ $folder_content = OC_FileCache::getFolderContent($this->path);
+ foreach($folder_content as $info) {
+ $nodes[] = $this->getChild($info['name'], $info);
}
return $nodes;
-
}
/**
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php
index 3ba1b3355f2..dd25df78c29 100644
--- a/lib/connector/sabre/file.php
+++ b/lib/connector/sabre/file.php
@@ -63,8 +63,8 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
* @return int
*/
public function getSize() {
- $this->stat();
- return $this->stat_cache['size'];
+ $this->getFileinfoCache();
+ return $this->fileinfo_cache['size'];
}
@@ -92,6 +92,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
* @return mixed
*/
public function getContentType() {
+ if (isset($this->fileinfo_cache['mimetype'])) {
+ return $this->fileinfo_cache['mimetype'];
+ }
return OC_Filesystem::getMimeType($this->path);
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
index e7bcea3171d..e5c059f0c8a 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/connector/sabre/node.php
@@ -33,7 +33,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* file stat cache
* @var array
*/
- protected $stat_cache;
+ protected $fileinfo_cache;
/**
* Sets up the node, expects a full path name
@@ -41,8 +41,11 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* @param string $path
* @return void
*/
- public function __construct($path) {
+ public function __construct($path, $fileinfo_cache = null) {
$this->path = $path;
+ if ($fileinfo_cache) {
+ $this->fileinfo_cache = $fileinfo_cache;
+ }
}
@@ -85,9 +88,14 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
/**
* Set the stat cache
*/
- protected function stat() {
- if (!isset($this->stat_cache)) {
- $this->stat_cache = OC_Filesystem::stat($this->path);
+ protected function getFileinfoCache() {
+ if (!isset($this->fileinfo_cache)) {
+ if ($fileinfo_cache = OC_FileCache::get($this->path)) {
+ } else {
+ $fileinfo_cache = OC_Filesystem::stat($this->path);
+ }
+
+ $this->fileinfo_cache = $fileinfo_cache;
}
}
@@ -97,8 +105,8 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* @return int
*/
public function getLastModified() {
- $this->stat();
- return $this->stat_cache['mtime'];
+ $this->getFileinfoCache();
+ return $this->fileinfo_cache['mtime'];
}