Skip to content

Commit

Permalink
Clear cached app config while waiting for the SCSSCache to finish pro…
Browse files Browse the repository at this point in the history
…cessing the file

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Oct 15, 2020
1 parent 87f8a09 commit 74c5b0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/private/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,14 @@ protected function loadConfigValues() {

$this->configLoaded = true;
}

/**
* Clear all the cached app config values
*
* WARNING: do not use this - this is only for usage with the SCSSCacher to
* clear the memory cache of the app config
*/
public function clearCachedConfig() {
$this->configLoaded = false;
}
}
8 changes: 7 additions & 1 deletion lib/private/Template/SCSSCacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

namespace OC\Template;

use OC\AppConfig;
use OC\Files\AppData\Factory;
use OC\Memcache\NullCache;
use OCP\AppFramework\Utility\ITimeFactory;
Expand Down Expand Up @@ -89,6 +90,8 @@ class SCSSCacher {

/** @var IMemcache */
private $lockingCache;
/** @var AppConfig */
private $appConfig;

/**
* @param ILogger $logger
Expand All @@ -109,7 +112,8 @@ public function __construct(ILogger $logger,
$serverRoot,
ICacheFactory $cacheFactory,
IconsCacher $iconsCacher,
ITimeFactory $timeFactory) {
ITimeFactory $timeFactory,
AppConfig $appConfig) {
$this->logger = $logger;
$this->appData = $appDataFactory->get('css');
$this->urlGenerator = $urlGenerator;
Expand All @@ -126,6 +130,7 @@ public function __construct(ILogger $logger,
$this->lockingCache = $lockingCache;
$this->iconsCacher = $iconsCacher;
$this->timeFactory = $timeFactory;
$this->appConfig = $appConfig;
}

/**
Expand Down Expand Up @@ -164,6 +169,7 @@ public function process(string $root, string $file, string $app): bool {
$retry = 0;
sleep(1);
while ($retry < 10) {
$this->appConfig->clearCachedConfig();
if (!$this->variablesChanged() && $this->isCached($fileNameCSS, $app)) {
// Inject icons vars css if any
$this->lockingCache->remove($lockKey);
Expand Down

0 comments on commit 74c5b0c

Please sign in to comment.