Skip to content

Commit

Permalink
Only shuffle when fork is installed (#142)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Hamp <[email protected]>
Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
3 people authored Jul 14, 2023
1 parent b737c7a commit 740d414
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Illuminate\Routing\Router;
use Illuminate\Support\Arr;
use League\Flysystem\Filesystem as Flysystem;
use Spatie\Fork\Fork;
use Statamic\Contracts\Imaging\UrlBuilder;
use Statamic\Facades\Collection;
use Statamic\Facades\Entry;
Expand Down Expand Up @@ -193,6 +192,10 @@ protected function createContentFiles($urls = '*')

$pages = $this->gatherContent($urls);

if (app('fork-installed') && $this->workers > 1) {
$pages = $pages->shuffle();
}

Partyline::line("Generating {$pages->count()} content files...");

$closures = $this->makeContentGenerationClosures($pages, $request);
Expand Down Expand Up @@ -254,8 +257,7 @@ protected function gatherAllPages()
->values()
->unique
->url()
->reject(fn ($page) => $this->shouldRejectPage($page))
->shuffle();
->reject(fn ($page) => $this->shouldRejectPage($page));
}

protected function makeContentGenerationClosures($pages, $request)
Expand Down Expand Up @@ -430,7 +432,7 @@ protected function updateCurrentSite($site)

protected function checkConcurrencySupport()
{
if ($this->workers === 1 || class_exists(Fork::class)) {
if ($this->workers === 1 || app('fork-installed')) {
return;
}

Expand Down

0 comments on commit 740d414

Please sign in to comment.