You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FillETags.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OC\Repair;
  25. use OCP\Migration\IOutput;
  26. use OCP\Migration\IRepairStep;
  27. class FillETags implements IRepairStep {
  28. /** @var \OCP\IDBConnection */
  29. protected $connection;
  30. /**
  31. * @param \OCP\IDBConnection $connection
  32. */
  33. public function __construct($connection) {
  34. $this->connection = $connection;
  35. }
  36. public function getName() {
  37. return 'Generate ETags for file where no ETag is present.';
  38. }
  39. public function run(IOutput $output) {
  40. $qb = $this->connection->getQueryBuilder();
  41. $qb->update('filecache')
  42. ->set('etag', $qb->expr()->literal('xxx'))
  43. ->where($qb->expr()->eq('etag', $qb->expr()->literal('')))
  44. ->orWhere($qb->expr()->isNull('etag'));
  45. $result = $qb->execute();
  46. $output->info("ETags have been fixed for $result files/folders.");
  47. }
  48. }