Skip to content

Commit d1693f4

Browse files
committed
allow to bypass immediate in generate conversions
1 parent 123acbb commit d1693f4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Commands/GenerateMediaConversionsCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111

1212
class GenerateMediaConversionsCommand extends Command
1313
{
14-
public $signature = 'media:generate-conversions {ids?*} {--force} {--pretend} {--conversions=*} {--collections=*} {--models=*}';
14+
public $signature = 'media:generate-conversions {ids?*} {--force} {--immediate} {--pretend} {--conversions=*} {--collections=*} {--models=*}';
1515

1616
public $description = 'Generate all media conversions';
1717

1818
public function handle(): int
1919
{
2020
$ids = (array) $this->argument('ids');
21+
$immediate = (bool) $this->option('immediate');
2122
$force = (bool) $this->option('force');
2223
$pretend = (bool) $this->option('pretend');
2324
/** @var string[] $conversions */
@@ -46,15 +47,17 @@ public function handle(): int
4647

4748
$progress = new Progress('Dispatching Media conversions', $count);
4849

49-
$query->chunkById(5_000, function ($items) use ($progress, $force, $conversions) {
50+
$query->chunkById(5_000, function ($items) use ($progress, $force, $immediate, $conversions) {
5051

5152
foreach ($items as $media) {
5253
/** @var Media $media */
5354
$media->dispatchConversions(
5455
queued: true,
55-
filter: function ($definition) use ($media, $force, $conversions) {
56+
filter: function ($definition) use ($media, $force, $immediate, $conversions) {
5657

57-
if (! $definition->immediate) {
58+
if (
59+
$immediate === false && ! $definition->immediate
60+
) {
5861
return false;
5962
}
6063

0 commit comments

Comments
 (0)