diff options
author | Robin Appelman <icewind@owncloud.com> | 2014-02-28 14:23:07 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-02-28 14:23:07 +0100 |
commit | da386aad5950235d6d1089f18b5ef4260057d78e (patch) | |
tree | 8fae5c0bcf5209cd477b181915f5dfa70228fa68 /lib/private/files/cache/homecache.php | |
parent | 8a93a2e7d50ab8526e551cf2677582492b835f82 (diff) | |
download | nextcloud-server-da386aad5950235d6d1089f18b5ef4260057d78e.tar.gz nextcloud-server-da386aad5950235d6d1089f18b5ef4260057d78e.zip |
Allow re-using already known fileinfo when calculating folder sizes
Diffstat (limited to 'lib/private/files/cache/homecache.php')
-rw-r--r-- | lib/private/files/cache/homecache.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/private/files/cache/homecache.php b/lib/private/files/cache/homecache.php index a7c310a3782..fad39a7fdad 100644 --- a/lib/private/files/cache/homecache.php +++ b/lib/private/files/cache/homecache.php @@ -13,15 +13,21 @@ class HomeCache extends Cache { * get the size of a folder and set it in the cache * * @param string $path + * @param array $entry (optional) meta data of the folder * @return int */ - public function calculateFolderSize($path) { + public function calculateFolderSize($path, $entry = null) { if ($path !== '/' and $path !== '' and $path !== 'files') { - return parent::calculateFolderSize($path); + return parent::calculateFolderSize($path, $entry); + } elseif ($path === '' or $path === '/') { + // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it + return 0; } $totalSize = 0; - $entry = $this->get($path); + if (is_null($entry)) { + $entry = $this->get($path); + } if ($entry && $entry['mimetype'] === 'httpd/unix-directory') { $id = $entry['fileid']; $sql = 'SELECT SUM(`size`) FROM `*PREFIX*filecache` ' . @@ -40,6 +46,7 @@ class HomeCache extends Cache { /** * @param string $path + * @return array */ public function get($path) { $data = parent::get($path); |