Close cursor early in calculateFolderSize

This method triggers additional queries in $this->update() so to avoid
potential database locks or delays, we close the cursor as soon as it is not needed any more
This commit is contained in:
Vincent Petry 2014-11-28 09:35:31 +01:00
parent 099d43b1f9
commit 35ab770b11
2 changed files with 4 additions and 0 deletions

View File

@ -596,6 +596,7 @@ class Cache {
'WHERE `parent` = ? AND `storage` = ?';
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
if ($row = $result->fetchRow()) {
$result->closeCursor();
list($sum, $min, $unencryptedSum) = array_values($row);
$sum = 0 + $sum;
$min = 0 + $min;
@ -618,6 +619,8 @@ class Cache {
if ($totalSize !== -1 and $unencryptedSum > 0) {
$totalSize = $unencryptedSum;
}
} else {
$result->closeCursor();
}
}
return $totalSize;

View File

@ -35,6 +35,7 @@ class HomeCache extends Cache {
'WHERE `parent` = ? AND `storage` = ? AND `size` >= 0';
$result = \OC_DB::executeAudited($sql, array($id, $this->getNumericStorageId()));
if ($row = $result->fetchRow()) {
$result->closeCursor();
list($sum, $unencryptedSum) = array_values($row);
$totalSize = 0 + $sum;
$unencryptedSize = 0 + $unencryptedSum;