Browse Source

Now calling parent method when path is not root

tags/list
Vincent Petry 10 years ago
parent
commit
1a65e3a725
1 changed files with 8 additions and 16 deletions
  1. 8
    16
      lib/private/files/cache/homecache.php

+ 8
- 16
lib/private/files/cache/homecache.php View File

@@ -16,31 +16,23 @@ class HomeCache extends Cache {
* @return int
*/
public function calculateFolderSize($path) {
if ($path !== '/' and $path !== '') {
return parent::calculateFolderSize($path);
}

$totalSize = 0;
$entry = $this->get($path);
if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
$isRoot = ($path === '/' or $path === '');
$id = $entry['fileid'];
$sql = 'SELECT SUM(`size`), MIN(`size`) FROM `*PREFIX*filecache` ' .
'WHERE `parent` = ? AND `storage` = ?';
if ($isRoot) {
// filter out non-scanned dirs at the root
$sql .= ' AND `size` >= 0';
}
$sql = 'SELECT SUM(`size`) FROM `*PREFIX*filecache` ' .
'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0';
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
if ($row = $result->fetchRow()) {
list($sum, $min) = array_values($row);
$sum = (int)$sum;
$min = (int)$min;
if ($min === -1) {
$totalSize = $min;
} else {
$totalSize = $sum;
}
list($sum) = array_values($row);
$totalSize = (int)$sum;
if ($entry['size'] !== $totalSize) {
$this->update($id, array('size' => $totalSize));
}

}
}
return $totalSize;

Loading…
Cancel
Save