1
0

ClearFrontendCaches.php 988 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC\Repair;
  7. use OC\Template\JSCombiner;
  8. use OCP\ICacheFactory;
  9. use OCP\Migration\IOutput;
  10. use OCP\Migration\IRepairStep;
  11. class ClearFrontendCaches implements IRepairStep {
  12. /** @var ICacheFactory */
  13. protected $cacheFactory;
  14. /** @var JSCombiner */
  15. protected $jsCombiner;
  16. public function __construct(ICacheFactory $cacheFactory,
  17. JSCombiner $JSCombiner) {
  18. $this->cacheFactory = $cacheFactory;
  19. $this->jsCombiner = $JSCombiner;
  20. }
  21. public function getName() {
  22. return 'Clear frontend caches';
  23. }
  24. public function run(IOutput $output) {
  25. try {
  26. $c = $this->cacheFactory->createDistributed('imagePath');
  27. $c->clear();
  28. $output->info('Image cache cleared');
  29. $this->jsCombiner->resetCache();
  30. $output->info('JS cache cleared');
  31. } catch (\Exception $e) {
  32. $output->warning('Unable to clear the frontend cache');
  33. }
  34. }
  35. }