Use query to calculate folder size
This commit is contained in:
parent
dd4e33fe6b
commit
1faac6108c
|
@ -489,19 +489,22 @@ class Cache {
|
||||||
$entry = $this->get($path);
|
$entry = $this->get($path);
|
||||||
if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
|
if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
|
||||||
$id = $entry['fileid'];
|
$id = $entry['fileid'];
|
||||||
$sql = 'SELECT `size` FROM `*PREFIX*filecache` WHERE `parent` = ? AND `storage` = ?';
|
$sql = 'SELECT SUM(`size`), MIN(`size`) FROM `*PREFIX*filecache` '.
|
||||||
|
'WHERE `parent` = ? AND `storage` = ?';
|
||||||
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
|
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
|
||||||
while ($row = $result->fetchRow()) {
|
if ($row = $result->fetchRow()) {
|
||||||
$size = (int)$row['size'];
|
list($sum, $min) = array_values($row);
|
||||||
if ($size === -1) {
|
$sum = (int)$sum;
|
||||||
$totalSize = -1;
|
$min = (int)$min;
|
||||||
break;
|
if ($min === -1) {
|
||||||
|
$totalSize = $min;
|
||||||
} else {
|
} else {
|
||||||
$totalSize += $size;
|
$totalSize = $sum;
|
||||||
}
|
}
|
||||||
}
|
if ($entry['size'] !== $totalSize) {
|
||||||
if ($entry['size'] !== $totalSize) {
|
$this->update($id, array('size' => $totalSize));
|
||||||
$this->update($id, array('size' => $totalSize));
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $totalSize;
|
return $totalSize;
|
||||||
|
|
Loading…
Reference in New Issue