Skip to content

Commit

Permalink
Let SCSS cleanup only run once (#17543)
Browse files Browse the repository at this point in the history
Let SCSS cleanup only run once
  • Loading branch information
skjnldsv committed Oct 17, 2019
2 parents 07dffb6 + ee74386 commit bd5189f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/private/Template/SCSSCacher.php
Expand Up @@ -117,7 +117,7 @@ public function __construct(ILogger $logger,
$this->serverRoot = $serverRoot;
$this->cacheFactory = $cacheFactory;
$this->depsCache = $cacheFactory->createDistributed('SCSS-deps-' . md5($this->urlGenerator->getBaseUrl()));
$this->isCachedCache = $cacheFactory->createLocal('SCSS-cached-' . md5($this->urlGenerator->getBaseUrl()));
$this->isCachedCache = $cacheFactory->createDistributed('SCSS-cached-' . md5($this->urlGenerator->getBaseUrl()));
$lockingCache = $cacheFactory->createDistributed('SCSS-locks-' . md5($this->urlGenerator->getBaseUrl()));
if (!($lockingCache instanceof IMemcache)) {
$lockingCache = new NullCache();
Expand Down Expand Up @@ -269,8 +269,8 @@ private function isCached(string $fileNameCSS, string $app) {
private function variablesChanged(): bool {
$injectedVariables = $this->getInjectedVariables();
if ($this->config->getAppValue('core', 'theming.variables') !== md5($injectedVariables)) {
$this->resetCache();
$this->config->setAppValue('core', 'theming.variables', md5($injectedVariables));
$this->resetCache();
return true;
}
return false;
Expand Down Expand Up @@ -364,6 +364,9 @@ private function cache(string $path, string $fileNameCSS, string $fileNameSCSS,
* We need to regenerate all files when variables change
*/
public function resetCache() {
if (!$this->lockingCache->add('resetCache', 'locked!', 120)) {
return;
}
$this->injectedVariables = null;

// do not clear locks
Expand All @@ -381,6 +384,7 @@ public function resetCache() {
}
}
$this->logger->debug('SCSSCacher: css cache cleared!');
$this->lockingCache->remove('resetCache');
}

/**
Expand Down

0 comments on commit bd5189f

Please sign in to comment.