diff options
author | Robin Appelman <robin@icewind.nl> | 2017-07-12 13:37:42 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-07-13 16:37:34 +0200 |
commit | 4a727a578ca1a75bfb85167d6a1b3fa3bbdf3a3e (patch) | |
tree | 060e0f2fec804c2def972b8b43f1ea867ca2bcf8 | |
parent | 598835b06fdd12a46253a44729eb602bc170b76b (diff) | |
download | nextcloud-server-4a727a578ca1a75bfb85167d6a1b3fa3bbdf3a3e.tar.gz nextcloud-server-4a727a578ca1a75bfb85167d6a1b3fa3bbdf3a3e.zip |
use a generator instead of fetching all rows at once
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/Repair/NC13/RepairInvalidPaths.php | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/private/Repair/NC13/RepairInvalidPaths.php b/lib/private/Repair/NC13/RepairInvalidPaths.php index 076fbb735c8..47a007baf5f 100644 --- a/lib/private/Repair/NC13/RepairInvalidPaths.php +++ b/lib/private/Repair/NC13/RepairInvalidPaths.php @@ -60,7 +60,10 @@ class RepairInvalidPaths implements IRepairStep { )) ->where($builder->expr()->neq('f.path', $computedPath)); - return $query->execute()->fetchAll(); + $result = $query->execute(); + while ($row = $result->fetch()) { + yield $row; + } } private function getId($storage, $path) { @@ -103,8 +106,11 @@ class RepairInvalidPaths implements IRepairStep { } private function repair() { + $this->connection->beginTransaction(); $entries = $this->getInvalidEntries(); + $count = 0; foreach ($entries as $entry) { + $count++; $calculatedPath = $entry['parent_path'] . '/' . $entry['name']; if ($newId = $this->getId($entry['storage'], $calculatedPath)) { // a new entry with the correct path has already been created, reuse that one and delete the incorrect entry @@ -114,7 +120,8 @@ class RepairInvalidPaths implements IRepairStep { $this->update($entry['fileid'], $calculatedPath); } } - return count($entries); + $this->connection->commit(); + return $count; } public function run(IOutput $output) { |