diff --git a/app/Console/Commands/ImageProcessing/GenerateThumbs.php b/app/Console/Commands/ImageProcessing/GenerateThumbs.php index 255e91eb69c..4dd0f4dd7e3 100644 --- a/app/Console/Commands/ImageProcessing/GenerateThumbs.php +++ b/app/Console/Commands/ImageProcessing/GenerateThumbs.php @@ -6,6 +6,7 @@ use App\Contracts\Exceptions\LycheeException; use App\Contracts\Models\SizeVariantFactory; use App\Enum\SizeVariantType; +use App\Exceptions\MediaFileOperationException; use App\Exceptions\UnexpectedException; use App\Models\Photo; use Illuminate\Console\Command; @@ -101,12 +102,19 @@ public function handle(): int $sizeVariantFactory = resolve(SizeVariantFactory::class); /** @var Photo $photo */ foreach ($photos as $photo) { - $sizeVariantFactory->init($photo); - $sizeVariant = $sizeVariantFactory->createSizeVariantCond($sizeVariantType); + $sizeVariant = null; + + try { + $sizeVariantFactory->init($photo); + $sizeVariant = $sizeVariantFactory->createSizeVariantCond($sizeVariantType); + } catch (MediaFileOperationException $e) { + $sizeVariant = null; + } + if ($sizeVariant !== null) { $this->line(' ' . $sizeVariantName . ' (' . $sizeVariant->width . 'x' . $sizeVariant->height . ') for ' . $photo->title . ' created.'); } else { - $this->line(' Did not create ' . $sizeVariantName . ' for ' . $photo->title . '.'); + $this->line(' Did not create ' . $sizeVariantName . ' for ' . $photo->id . ' .'); } $bar->advance(); } diff --git a/app/Http/Controllers/Admin/Maintenance/GenSizeVariants.php b/app/Http/Controllers/Admin/Maintenance/GenSizeVariants.php index b1550a2d5a1..327ec939742 100644 --- a/app/Http/Controllers/Admin/Maintenance/GenSizeVariants.php +++ b/app/Http/Controllers/Admin/Maintenance/GenSizeVariants.php @@ -4,6 +4,7 @@ use App\Contracts\Models\SizeVariantFactory; use App\Enum\SizeVariantType; +use App\Exceptions\MediaFileOperationException; use App\Http\Requests\Maintenance\CreateThumbsRequest; use App\Image\PlaceholderEncoder; use App\Image\SizeVariantDimensionHelpers; @@ -41,15 +42,19 @@ public function do(CreateThumbsRequest $request, SizeVariantFactory $sizeVariant foreach ($photos as $photo) { // @codeCoverageIgnoreStart $sizeVariantFactory->init($photo); - $sizeVariant = $sizeVariantFactory->createSizeVariantCond($request->kind()); - if ($request->kind() === SizeVariantType::PLACEHOLDER && $sizeVariant !== null) { - $placeholderEncoder->do($sizeVariant); - } - if ($sizeVariant !== null) { - $generated++; - Log::notice($request->kind()->value . ' (' . $sizeVariant->width . 'x' . $sizeVariant->height . ') for ' . $photo->title . ' created.'); - } else { - Log::error('Did not create ' . $request->kind()->value . ' for ' . $photo->title . '.'); + try { + $sizeVariant = $sizeVariantFactory->createSizeVariantCond($request->kind()); + if ($request->kind() === SizeVariantType::PLACEHOLDER && $sizeVariant !== null) { + $placeholderEncoder->do($sizeVariant); + } + if ($sizeVariant !== null) { + $generated++; + Log::notice($request->kind()->value . ' (' . $sizeVariant->width . 'x' . $sizeVariant->height . ') for ' . $photo->title . ' created.'); + } else { + Log::error('Did not create ' . $request->kind()->value . ' for ' . $photo->title . '.'); + } + } catch (MediaFileOperationException $e) { + Log::error('Failed to create ' . $request->kind()->value . ' for photo id ' . $photo->id . ''); } // @codeCoverageIgnoreEnd } diff --git a/app/Http/Controllers/Admin/Maintenance/MissingFileSizes.php b/app/Http/Controllers/Admin/Maintenance/MissingFileSizes.php index 4ca226e6156..454ad0849e3 100644 --- a/app/Http/Controllers/Admin/Maintenance/MissingFileSizes.php +++ b/app/Http/Controllers/Admin/Maintenance/MissingFileSizes.php @@ -44,7 +44,7 @@ public function do(MaintenanceRequest $request): void } else { $generated++; } - } catch (UnableToRetrieveMetadata $e) { + } catch (UnableToRetrieveMetadata) { Log::error($variant->id . ' : Failed to get filesize for ' . $variantFile->getRelativePath() . '.'); } } else {