Skip to content

Commit

Permalink
fix page scanner file cache
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDev committed Jan 11, 2021
1 parent b010f59 commit 0681237
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/page-scanner/src/PageScannerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
$this->pageClass = $pageClass;
$this->em = $em;
$this->filesystem = $filesystem;
PageScannerController::$fileCache = $varDir.PageScannerController::$fileCache;
PageScannerController::setFileCache($varDir);
}

protected function configure()
Expand All @@ -48,7 +48,7 @@ protected function scanAllWithLock(string $host)
//sleep(30);
$errors = $this->scanAll($host);
//dd($errors);
$this->filesystem->dumpFile(PageScannerController::$fileCache, serialize($errors));
$this->filesystem->dumpFile(PageScannerController::fileCache(), serialize($errors));
$lock->release();

return true;
Expand Down
19 changes: 17 additions & 2 deletions packages/page-scanner/src/PageScannerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Pushword\PageScanner;

use DateInterval;
use Exception;
use Pushword\Core\Utils\LastTime;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Container;
Expand All @@ -28,14 +29,28 @@ class PageScannerController extends AbstractController
protected $filesystem;
protected $eventDispatcher;

public static $fileCache = '/page-scan';
protected static $fileCache;

public function __construct(
Filesystem $filesystem,
string $varDir
) {
$this->filesystem = $filesystem;
self::$fileCache = $varDir.self::$fileCache;
$this->setFileCache($varDir);
}

public static function setFileCache(string $varDir): void
{
self::$fileCache = self::$fileCache ?: $varDir.'/page-scan';
}

public static function fileCache(): string
{
if (! \is_string(self::$fileCache)) {
throw new Exception('setFileCache($varDir) must be setted before call fileCache()');
}

return self::$fileCache;
}

public function scanAction()
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/skeleton/var/page-scan

Large diffs are not rendered by default.

0 comments on commit 0681237

Please sign in to comment.