diff options
Diffstat (limited to 'apps/files/lib/Command/RepairTree.php')
-rw-r--r-- | apps/files/lib/Command/RepairTree.php | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/apps/files/lib/Command/RepairTree.php b/apps/files/lib/Command/RepairTree.php index 144ce5654eb..622ccba48a3 100644 --- a/apps/files/lib/Command/RepairTree.php +++ b/apps/files/lib/Command/RepairTree.php @@ -1,26 +1,11 @@ <?php declare(strict_types=1); + /** - * @copyright Copyright (c) 2021 Robin Appelman <robin@icewind.nl> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ - namespace OCA\Files\Command; use OCP\IDBConnection; @@ -31,17 +16,13 @@ use Symfony\Component\Console\Output\OutputInterface; class RepairTree extends Command { public const CHUNK_SIZE = 200; - /** - * @var IDBConnection - */ - protected $connection; - - public function __construct(IDBConnection $connection) { - $this->connection = $connection; + public function __construct( + protected IDBConnection $connection, + ) { parent::__construct(); } - protected function configure() { + protected function configure(): void { $this ->setName('files:repair-tree') ->setDescription('Try and repair malformed filesystem tree structures') @@ -52,7 +33,7 @@ class RepairTree extends Command { $rows = $this->findBrokenTreeBits(); $fix = !$input->getOption('dry-run'); - $output->writeln("Found " . count($rows) . " file entries with an invalid path"); + $output->writeln('Found ' . count($rows) . ' file entries with an invalid path'); if ($fix) { $this->connection->beginTransaction(); @@ -66,7 +47,7 @@ class RepairTree extends Command { ->where($query->expr()->eq('fileid', $query->createParameter('fileid'))); foreach ($rows as $row) { - $output->writeln("Path of file ${row['fileid']} is ${row['path']} but should be ${row['parent_path']}/${row['name']} based on it's parent", OutputInterface::VERBOSITY_VERBOSE); + $output->writeln("Path of file {$row['fileid']} is {$row['path']} but should be {$row['parent_path']}/{$row['name']} based on its parent", OutputInterface::VERBOSITY_VERBOSE); if ($fix) { $fileId = $this->getFileId((int)$row['parent_storage'], $row['parent_path'] . '/' . $row['name']); @@ -88,7 +69,7 @@ class RepairTree extends Command { $this->connection->commit(); } - return 0; + return self::SUCCESS; } private function getFileId(int $storage, string $path) { @@ -100,7 +81,7 @@ class RepairTree extends Command { return $query->execute()->fetch(\PDO::FETCH_COLUMN); } - private function deleteById(int $fileId) { + private function deleteById(int $fileId): void { $query = $this->connection->getQueryBuilder(); $query->delete('filecache') ->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId))); |