summaryrefslogtreecommitdiffstats
path: root/lib/private/Repair
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-01-26 17:46:42 +0100
committerJulius Härtl <jus@bitgrid.net>2018-02-03 15:21:51 +0100
commit7381a81d3041a3460617623028d6e8cfb5391649 (patch)
tree5bee0985b80aa30bf7d925cbee589e8da74d19fc /lib/private/Repair
parent79e81c15c5beb4174922921083f0e838de9a3bfc (diff)
downloadnextcloud-server-7381a81d3041a3460617623028d6e8cfb5391649.tar.gz
nextcloud-server-7381a81d3041a3460617623028d6e8cfb5391649.zip
Add repair step to clear frontend related caches
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/Repair')
-rw-r--r--lib/private/Repair/ClearFrontendCaches.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/lib/private/Repair/ClearFrontendCaches.php b/lib/private/Repair/ClearFrontendCaches.php
new file mode 100644
index 00000000000..8d109462f6a
--- /dev/null
+++ b/lib/private/Repair/ClearFrontendCaches.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
+ *
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @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/>.
+ *
+ */
+
+namespace OC\Repair;
+
+use OC\Core\Command\Maintenance\ClearCacheJSCSS;
+use OC\Template\JSCombiner;
+use OC\Template\SCSSCacher;
+use OCP\AppFramework\QueryException;
+use OCP\ICacheFactory;
+use OCP\Migration\IOutput;
+use OCP\Migration\IRepairStep;
+use Symfony\Component\Console\Input\StringInput;
+use Symfony\Component\Console\Output\BufferedOutput;
+
+class ClearFrontendCaches implements IRepairStep {
+
+ /** @var ICacheFactory */
+ protected $cacheFactory;
+
+ /** @var SCSSCacher */
+ protected $scssCacher;
+
+ /** @var JSCombiner */
+ protected $jsCombiner;
+
+ public function __construct(ICacheFactory $cacheFactory,
+ SCSSCacher $SCSSCacher,
+ JSCombiner $JSCombiner) {
+ $this->cacheFactory = $cacheFactory;
+ $this->scssCacher = $SCSSCacher;
+ $this->jsCombiner = $JSCombiner;
+ }
+
+ public function getName() {
+ return 'Clear frontend caches';
+ }
+
+ public function run(IOutput $output) {
+ try {
+ $c = $this->cacheFactory->createDistributed('imagePath');
+ $c->clear('');
+ $output->info('Image cache cleared');
+
+ $this->scssCacher->resetCache();
+ $c = $this->cacheFactory->createDistributed('SCSS');
+ $c->clear('');
+ $output->info('SCSS cache cleared');
+
+ $this->jsCombiner->resetCache();
+ $c = $this->cacheFactory->createDistributed('JS');
+ $c->clear('');
+ $output->info('JS cache cleared');
+ } catch (\Exception $e) {
+ $output->warning('Unable to clear the frontend cache');
+ }
+ }
+}