Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Oct 20, 2024
1 parent d1693f4 commit 05dbb74
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
51 changes: 29 additions & 22 deletions src/Commands/GenerateMediaConversionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,40 @@ public function handle(): int

foreach ($items as $media) {
/** @var Media $media */
$media->dispatchConversions(
queued: true,
filter: function ($definition) use ($media, $force, $immediate, $conversions) {

if (
$immediate === false && ! $definition->immediate
) {
return false;
}

if (! empty($conversions)) {
foreach ($conversions as $conversion) {
if (
! empty($conversions) &&
! in_array($definition->name, $conversions)
$force === false &&
$media->hasConversion($conversion)
) {
return false;
continue;
}

if (
! $force &&
$media->hasConversion($definition->name)
) {
return false;
}

return true;
$media->dispatchConversion($conversion);
}
);
} else {
$media->dispatchConversions(
queued: true,
filter: function ($definition) use ($media, $force, $immediate) {

if (
$immediate === false &&
! $definition->immediate
) {
return false;
}

if (
$force === false &&
$media->hasConversion($definition->name)
) {
return false;
}

return true;
}
);
}

$progress->advance();
}
Expand Down
6 changes: 5 additions & 1 deletion src/Models/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ public function getChildrenConversionsDefinitions(string $name): array
public function dispatchConversion(string $conversion): ?PendingDispatch
{
if ($definition = $this->getConversionDefinition($conversion)) {
return $definition->dispatch($this, $this->getParentConversion($conversion));
$parent = $this->getParentConversion($conversion);

if ($definition->shouldExecute($this, $parent)) {
return $definition->dispatch($this, $parent);
}
}

return null;
Expand Down

0 comments on commit 05dbb74

Please sign in to comment.