feat(thumbnailer): purge cache for file when handling :replace_original from processors (#256)

This commit is contained in:
mdashlw 2024-05-11 19:04:52 +03:00 committed by GitHub
parent 0e0c446579
commit d76be72a5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,6 +5,7 @@ defmodule Philomena.Images.Thumbnailer do
alias Philomena.DuplicateReports alias Philomena.DuplicateReports
alias Philomena.ImageIntensities alias Philomena.ImageIntensities
alias Philomena.ImagePurgeWorker
alias Philomena.Images.Image alias Philomena.Images.Image
alias Philomena.Processors alias Philomena.Processors
alias Philomena.Analyzers alias Philomena.Analyzers
@ -103,8 +104,14 @@ defmodule Philomena.Images.Thumbnailer do
defp apply_change(image, {:intensities, intensities}), defp apply_change(image, {:intensities, intensities}),
do: ImageIntensities.create_image_intensity(image, intensities) do: ImageIntensities.create_image_intensity(image, intensities)
defp apply_change(image, {:replace_original, new_file}), defp apply_change(image, {:replace_original, new_file}) do
do: upload_file(image, new_file, "full.#{image.image_format}") full = "full.#{image.image_format}"
upload_file(image, new_file, full)
Exq.enqueue(Exq, "indexing", ImagePurgeWorker, [
Path.join(image_url_base(image, nil), full)
])
end
defp apply_change(image, {:thumbnails, thumbnails}), defp apply_change(image, {:thumbnails, thumbnails}),
do: Enum.map(thumbnails, &apply_thumbnail(image, &1)) do: Enum.map(thumbnails, &apply_thumbnail(image, &1))