Skip to content

Commit

Permalink
Поправил сканирование и очистку кеша
Browse files Browse the repository at this point in the history
  • Loading branch information
visavi committed Jun 18, 2021
1 parent b61fe90 commit 612cd23
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 3,408 deletions.
15 changes: 8 additions & 7 deletions app/Http/Controllers/Admin/CacheController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
use Illuminate\View\View;

class CacheController extends AdminController
Expand All @@ -25,10 +26,10 @@ public function index(Request $request): View
$files = glob(public_path('uploads/thumbnails/*.{gif,png,jpg,jpeg}'), GLOB_BRACE);
$files = paginate($files, 20, compact('type'));
} elseif ($type === 'views') {
$files = glob(storage_path('views/*.php'), GLOB_BRACE);
$files = glob(storage_path('framework/views/*.php'), GLOB_BRACE);
$files = paginate($files, 20, compact('type'));
} else {
$files = glob(storage_path('caches/{*/*/*,*.php}'), GLOB_BRACE);
$files = glob(storage_path('framework/cache/data/*/*/*'));
$files = paginate($files, 20, compact('type'));
}

Expand All @@ -49,15 +50,15 @@ public function clear(Request $request): RedirectResponse
if ($request->input('_token') === csrf_token()) {
switch ($type) {
case 'images':
runCommand(new ImageClear());
Artisan::call('image:clear');
break;
case 'views':
runCommand(new ViewClear());
Artisan::call('view:clear');
break;
default:
runCommand(new ConfigClear());
runCommand(new RouteClear());
runCommand(new CacheClear());
Artisan::call('cache:clear');
Artisan::call('route:clear');
Artisan::call('config:clear');
}

setFlash('success', __('admin.caches.success_cleared'));
Expand Down
7 changes: 4 additions & 3 deletions app/Http/Controllers/Admin/CheckerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public function index(): View
{
$diff = [];

if (file_exists(storage_path('caches/checker.php'))) {
if (file_exists(storage_path('framework/cache/checker.php'))) {
$files = $this->scanFiles(base_path());
$filesScan = json_decode(file_get_contents(storage_path('caches/checker.php')), true);
$filesScan = json_decode(file_get_contents(storage_path('framework/cache/checker.php')), true);

$diff['left'] = array_diff($files, $filesScan);
$diff['right'] = array_diff($filesScan, $files);
Expand All @@ -44,7 +44,7 @@ public function scan(Request $request): RedirectResponse
if ($request->input('_token') === csrf_token()) {
$files = $this->scanFiles(base_path());

file_put_contents(storage_path('caches/checker.php'), json_encode($files));
file_put_contents(storage_path('framework/cache/checker.php'), json_encode($files));

setFlash('success', __('admin.checkers.success_crawled'));
} else {
Expand All @@ -69,6 +69,7 @@ private function scanFiles(string $dir): array
$finder = new Finder();
$files = $finder->in($dir)
->files()
->exclude(basename(storage_path()))
->notName($excludeFiles);

if (file_exists(base_path('.gitignore'))) {
Expand Down
4 changes: 2 additions & 2 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ function statsStickers(): int
*/
function statsChecker()
{
if (file_exists(storage_path('caches/checker.php'))) {
return dateFixed(filemtime(storage_path('caches/checker.php')), 'd.m.Y');
if (file_exists(storage_path('framework/cache/checker.php'))) {
return dateFixed(filemtime(storage_path('framework/cache/checker.php')), 'd.m.Y');
}

return 0;
Expand Down
Loading

0 comments on commit 612cd23

Please sign in to comment.