2018-01-26 11:46:42 -05:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2026-02-09 04:53:58 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2018-01-26 11:46:42 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2018-01-26 11:46:42 -05:00
|
|
|
*/
|
|
|
|
|
namespace OC\Repair;
|
|
|
|
|
|
2019-11-22 14:52:10 -05:00
|
|
|
use OC\Template\JSCombiner;
|
2018-01-26 11:46:42 -05:00
|
|
|
use OCP\ICacheFactory;
|
|
|
|
|
use OCP\Migration\IOutput;
|
|
|
|
|
use OCP\Migration\IRepairStep;
|
|
|
|
|
|
|
|
|
|
class ClearFrontendCaches implements IRepairStep {
|
2025-11-17 09:32:54 -05:00
|
|
|
public function __construct(
|
|
|
|
|
protected ICacheFactory $cacheFactory,
|
|
|
|
|
protected JSCombiner $jsCombiner,
|
|
|
|
|
) {
|
2018-01-26 11:46:42 -05:00
|
|
|
}
|
|
|
|
|
|
2025-11-24 03:17:34 -05:00
|
|
|
public function getName(): string {
|
2018-01-26 11:46:42 -05:00
|
|
|
return 'Clear frontend caches';
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-24 03:17:34 -05:00
|
|
|
public function run(IOutput $output): void {
|
2018-01-26 11:46:42 -05:00
|
|
|
try {
|
|
|
|
|
$c = $this->cacheFactory->createDistributed('imagePath');
|
2018-02-03 06:41:21 -05:00
|
|
|
$c->clear();
|
2018-01-26 11:46:42 -05:00
|
|
|
$output->info('Image cache cleared');
|
|
|
|
|
|
|
|
|
|
$this->jsCombiner->resetCache();
|
|
|
|
|
$output->info('JS cache cleared');
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$output->warning('Unable to clear the frontend cache');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|