summaryrefslogtreecommitdiffstats
path: root/lib/connector/sabre/node.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-06-15 16:04:01 +0200
committerBart Visscher <bartv@thisnet.nl>2012-06-15 16:04:07 +0200
commit400769ab400f8c57b95d762420ff2b8da62738a3 (patch)
treed92aca54a7aa75e92a7837b6ff49bba0e697da15 /lib/connector/sabre/node.php
parent8f6121ffa8dfd5ee85ba70569587e2b1878084cd (diff)
downloadnextcloud-server-400769ab400f8c57b95d762420ff2b8da62738a3.tar.gz
nextcloud-server-400769ab400f8c57b95d762420ff2b8da62738a3.zip
Optimize WebDav access using OC_FileCache
Diffstat (limited to 'lib/connector/sabre/node.php')
-rw-r--r--lib/connector/sabre/node.php22
1 files changed, 15 insertions, 7 deletions
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'];
}