]> source.dussan.org Git - nextcloud-server.git/commitdiff
Close cursor early in calculateFolderSize
authorVincent Petry <pvince81@owncloud.com>
Fri, 28 Nov 2014 08:35:31 +0000 (09:35 +0100)
committerVincent Petry <pvince81@owncloud.com>
Fri, 28 Nov 2014 08:35:31 +0000 (09:35 +0100)
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

lib/private/files/cache/cache.php
lib/private/files/cache/homecache.php

index 8831320bcee0bc4b2190d4ad508651b127b19b58..5438bdad5cbfc61e6f9f1b64ce3c8beaed6d20bd 100644 (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;
index 2b3967c8807dfa8bbbfaf4d8ad9b6ed2ed9d8135..ad7f587b8b6d72d857ca9462562a6af31be57fe3 100644 (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;