diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2013-07-28 16:14:49 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2013-07-28 16:14:49 -0400 |
commit | dd4e33fe6b1cf9feccaeae33c81fc8b08fb24d4d (patch) | |
tree | 8497f1dc51d69fabfce482786461f50232692079 | |
parent | 48621115c10f62f776dbe41ad9a51c1ac360fc8c (diff) | |
download | nextcloud-server-dd4e33fe6b1cf9feccaeae33c81fc8b08fb24d4d.tar.gz nextcloud-server-dd4e33fe6b1cf9feccaeae33c81fc8b08fb24d4d.zip |
Fix calculating size for empty folders
-rw-r--r-- | lib/files/cache/cache.php | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php index 3818fdbd840..458df56141c 100644 --- a/lib/files/cache/cache.php +++ b/lib/files/cache/cache.php @@ -485,27 +485,24 @@ class Cache { * @return int */ public function calculateFolderSize($path) { - $id = $this->getId($path); - if ($id === -1) { - return 0; - } - $sql = 'SELECT `size` FROM `*PREFIX*filecache` WHERE `parent` = ? AND `storage` = ?'; - $result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId())); $totalSize = 0; - $hasChilds = 0; - while ($row = $result->fetchRow()) { - $hasChilds = true; - $size = (int)$row['size']; - if ($size === -1) { - $totalSize = -1; - break; - } else { - $totalSize += $size; + $entry = $this->get($path); + if ($entry && $entry['mimetype'] === 'httpd/unix-directory') { + $id = $entry['fileid']; + $sql = 'SELECT `size` FROM `*PREFIX*filecache` WHERE `parent` = ? AND `storage` = ?'; + $result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId())); + while ($row = $result->fetchRow()) { + $size = (int)$row['size']; + if ($size === -1) { + $totalSize = -1; + break; + } else { + $totalSize += $size; + } + } + if ($entry['size'] !== $totalSize) { + $this->update($id, array('size' => $totalSize)); } - } - - if ($hasChilds) { - $this->update($id, array('size' => $totalSize)); } return $totalSize; } |