diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-06-08 20:26:08 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-06-08 21:38:10 +0200 |
commit | d9d6876be9bbf32c39f676e3d6cbab85e57abd34 (patch) | |
tree | 763517a77177c04218cb2fb7bcc909b08d16a5d9 /lib/connector | |
parent | 7c5c257bf69f77cea599bdf641676977009ee162 (diff) | |
download | nextcloud-server-d9d6876be9bbf32c39f676e3d6cbab85e57abd34.tar.gz nextcloud-server-d9d6876be9bbf32c39f676e3d6cbab85e57abd34.zip |
Add stat cache to OC_Connector_Sabre_Node and OC_Connector_Sabre_File
Speeds up access of directories with large number of files.
Diffstat (limited to 'lib/connector')
-rw-r--r-- | lib/connector/sabre/file.php | 4 | ||||
-rw-r--r-- | lib/connector/sabre/node.php | 18 |
2 files changed, 17 insertions, 5 deletions
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index f2efe0a5ac1..3ba1b3355f2 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() { - - return OC_Filesystem::filesize($this->path); + $this->stat(); + return $this->stat_cache['size']; } diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index bb367a18c42..e7bcea3171d 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -29,6 +29,11 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @var string */ protected $path; + /** + * file stat cache + * @var array + */ + protected $stat_cache; /** * Sets up the node, expects a full path name @@ -77,7 +82,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); + } + } /** * Returns the last modification time, as a unix timestamp @@ -85,8 +97,8 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @return int */ public function getLastModified() { - - return OC_Filesystem::filemtime($this->path); + $this->stat(); + return $this->stat_cache['mtime']; } |