|
|
@@ -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; |