Move depsCache clearing to SCSSCacher/JSCombiner
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
5460166ff5
commit
b87e5a0f2e
|
@ -23,15 +23,11 @@
|
||||||
|
|
||||||
namespace OC\Repair;
|
namespace OC\Repair;
|
||||||
|
|
||||||
use OC\Core\Command\Maintenance\ClearCacheJSCSS;
|
|
||||||
use OC\Template\JSCombiner;
|
use OC\Template\JSCombiner;
|
||||||
use OC\Template\SCSSCacher;
|
use OC\Template\SCSSCacher;
|
||||||
use OCP\AppFramework\QueryException;
|
|
||||||
use OCP\ICacheFactory;
|
use OCP\ICacheFactory;
|
||||||
use OCP\Migration\IOutput;
|
use OCP\Migration\IOutput;
|
||||||
use OCP\Migration\IRepairStep;
|
use OCP\Migration\IRepairStep;
|
||||||
use Symfony\Component\Console\Input\StringInput;
|
|
||||||
use Symfony\Component\Console\Output\BufferedOutput;
|
|
||||||
|
|
||||||
class ClearFrontendCaches implements IRepairStep {
|
class ClearFrontendCaches implements IRepairStep {
|
||||||
|
|
||||||
|
@ -59,17 +55,13 @@ class ClearFrontendCaches implements IRepairStep {
|
||||||
public function run(IOutput $output) {
|
public function run(IOutput $output) {
|
||||||
try {
|
try {
|
||||||
$c = $this->cacheFactory->createDistributed('imagePath');
|
$c = $this->cacheFactory->createDistributed('imagePath');
|
||||||
$c->clear('');
|
$c->clear();
|
||||||
$output->info('Image cache cleared');
|
$output->info('Image cache cleared');
|
||||||
|
|
||||||
$this->scssCacher->resetCache();
|
$this->scssCacher->resetCache();
|
||||||
$c = $this->cacheFactory->createDistributed('SCSS');
|
|
||||||
$c->clear('');
|
|
||||||
$output->info('SCSS cache cleared');
|
$output->info('SCSS cache cleared');
|
||||||
|
|
||||||
$this->jsCombiner->resetCache();
|
$this->jsCombiner->resetCache();
|
||||||
$c = $this->cacheFactory->createDistributed('JS');
|
|
||||||
$c->clear('');
|
|
||||||
$output->info('JS cache cleared');
|
$output->info('JS cache cleared');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$output->warning('Unable to clear the frontend cache');
|
$output->warning('Unable to clear the frontend cache');
|
||||||
|
|
|
@ -236,10 +236,8 @@ class JSCombiner {
|
||||||
* @throws NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function resetCache() {
|
public function resetCache() {
|
||||||
|
$this->depsCache->clear();
|
||||||
$appDirectory = $this->appData->getDirectoryListing();
|
$appDirectory = $this->appData->getDirectoryListing();
|
||||||
if(empty($appDirectory)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
foreach ($appDirectory as $folder) {
|
foreach ($appDirectory as $folder) {
|
||||||
foreach ($folder->getDirectoryListing() as $file) {
|
foreach ($folder->getDirectoryListing() as $file) {
|
||||||
$file->delete();
|
$file->delete();
|
||||||
|
|
|
@ -263,10 +263,8 @@ class SCSSCacher {
|
||||||
*/
|
*/
|
||||||
public function resetCache() {
|
public function resetCache() {
|
||||||
$this->injectedVariables = null;
|
$this->injectedVariables = null;
|
||||||
|
$this->depsCache->clear();
|
||||||
$appDirectory = $this->appData->getDirectoryListing();
|
$appDirectory = $this->appData->getDirectoryListing();
|
||||||
if(empty($appDirectory)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
foreach ($appDirectory as $folder) {
|
foreach ($appDirectory as $folder) {
|
||||||
foreach ($folder->getDirectoryListing() as $file) {
|
foreach ($folder->getDirectoryListing() as $file) {
|
||||||
$file->delete();
|
$file->delete();
|
||||||
|
|
|
@ -63,14 +63,6 @@ class ClearFrontendCachesTest extends \Test\TestCase {
|
||||||
$imagePathCache->expects($this->once())
|
$imagePathCache->expects($this->once())
|
||||||
->method('clear')
|
->method('clear')
|
||||||
->with('');
|
->with('');
|
||||||
$jsCache = $this->createMock(ICache::class);
|
|
||||||
$jsCache->expects($this->once())
|
|
||||||
->method('clear')
|
|
||||||
->with('');
|
|
||||||
$cssCache = $this->createMock(ICache::class);
|
|
||||||
$cssCache->expects($this->once())
|
|
||||||
->method('clear')
|
|
||||||
->with('');
|
|
||||||
$this->jsCombiner->expects($this->once())
|
$this->jsCombiner->expects($this->once())
|
||||||
->method('resetCache');
|
->method('resetCache');
|
||||||
$this->scssCacher->expects($this->once())
|
$this->scssCacher->expects($this->once())
|
||||||
|
@ -79,14 +71,6 @@ class ClearFrontendCachesTest extends \Test\TestCase {
|
||||||
->method('createDistributed')
|
->method('createDistributed')
|
||||||
->with('imagePath')
|
->with('imagePath')
|
||||||
->willReturn($imagePathCache);
|
->willReturn($imagePathCache);
|
||||||
$this->cacheFactory->expects($this->at(1))
|
|
||||||
->method('createDistributed')
|
|
||||||
->with('SCSS')
|
|
||||||
->willReturn($cssCache);
|
|
||||||
$this->cacheFactory->expects($this->at(2))
|
|
||||||
->method('createDistributed')
|
|
||||||
->with('JS')
|
|
||||||
->willReturn($jsCache);
|
|
||||||
|
|
||||||
$this->repair->run($this->outputMock);
|
$this->repair->run($this->outputMock);
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
|
|
|
@ -511,4 +511,25 @@ var b = \'world\';
|
||||||
$expected = [];
|
$expected = [];
|
||||||
$this->assertEquals($expected, $this->jsCombiner->getContent($pathInfo['dirname'], $pathInfo['basename']));
|
$this->assertEquals($expected, $this->jsCombiner->getContent($pathInfo['dirname'], $pathInfo['basename']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testResetCache() {
|
||||||
|
$file = $this->createMock(ISimpleFile::class);
|
||||||
|
$file->expects($this->once())
|
||||||
|
->method('delete');
|
||||||
|
|
||||||
|
$folder = $this->createMock(ISimpleFolder::class);
|
||||||
|
$folder->expects($this->once())
|
||||||
|
->method('getDirectoryListing')
|
||||||
|
->willReturn([$file]);
|
||||||
|
|
||||||
|
$this->depsCache->expects($this->once())
|
||||||
|
->method('clear')
|
||||||
|
->with('');
|
||||||
|
$this->appData->expects($this->once())
|
||||||
|
->method('getDirectoryListing')
|
||||||
|
->willReturn([$folder]);
|
||||||
|
|
||||||
|
$this->jsCombiner->resetCache();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,4 +445,25 @@ class SCSSCacherTest extends \Test\TestCase {
|
||||||
$this->rrmdir($tmpDir.$path);
|
$this->rrmdir($tmpDir.$path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testResetCache() {
|
||||||
|
$file = $this->createMock(ISimpleFile::class);
|
||||||
|
$file->expects($this->once())
|
||||||
|
->method('delete');
|
||||||
|
|
||||||
|
$folder = $this->createMock(ISimpleFolder::class);
|
||||||
|
$folder->expects($this->once())
|
||||||
|
->method('getDirectoryListing')
|
||||||
|
->willReturn([$file]);
|
||||||
|
|
||||||
|
$this->depsCache->expects($this->once())
|
||||||
|
->method('clear')
|
||||||
|
->with('');
|
||||||
|
$this->appData->expects($this->once())
|
||||||
|
->method('getDirectoryListing')
|
||||||
|
->willReturn([$folder]);
|
||||||
|
|
||||||
|
$this->scssCacher->resetCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue