diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 9ca3ece6dd493..30240dfb60b70 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -83,6 +83,7 @@ use OC\Repair\RepairDavShares; use OC\Repair\RepairInvalidShares; use OC\Repair\RepairMimeTypes; +use OC\Repair\RepairUnencryptedSize; use OC\Repair\SqliteAutoincrement; use OC\Template\JSCombiner; use Psr\Log\LoggerInterface; @@ -176,6 +177,7 @@ public static function getRepairSteps(): array { return [ new Collation(\OC::$server->getConfig(), \OC::$server->get(LoggerInterface::class), \OC::$server->getDatabaseConnection(), false), new RepairMimeTypes(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), + new RepairUnencryptedSize(\OC::$server->getDatabaseConnection()), new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()), new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()), new MoveUpdaterStepFile(\OC::$server->getConfig()), diff --git a/lib/private/Repair/RepairUnencryptedSize.php b/lib/private/Repair/RepairUnencryptedSize.php new file mode 100644 index 0000000000000..08f4455a7d2d7 --- /dev/null +++ b/lib/private/Repair/RepairUnencryptedSize.php @@ -0,0 +1,55 @@ + + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * 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, version 3, + * along with this program. If not, see + * + */ +namespace OC\Repair; + +use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\IDBConnection; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; + +class RepairUnencryptedSize implements IRepairStep { + /** @var IDBConnection */ + protected $connection; + + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + } + + public function getName() { + return 'Repair file size of unencrypted files'; + } + + /** + * Fix unencrypted file size + */ + public function run(IOutput $output) { + $update = $this->connection->getQueryBuilder(); + $update->update('filecache') + ->set('unencrypted_size', "0") + ->where($update->expr()->gt('unencrypted_size', "0", IQueryBuilder::PARAM_INT)) + ->andWhere($update->expr()->eq('encrypted', "0", IQueryBuilder::PARAM_INT)); + + if ($update->execute()) { + $output->info('Fixed file size of unencrypted files'); + } + } +}