From d76be72a5de0969e01bde4bd0743c4a3e3cab144 Mon Sep 17 00:00:00 2001 From: mdashlw Date: Sat, 11 May 2024 19:04:52 +0300 Subject: [PATCH] feat(thumbnailer): purge cache for file when handling :replace_original from processors (#256) --- lib/philomena/images/thumbnailer.ex | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/philomena/images/thumbnailer.ex b/lib/philomena/images/thumbnailer.ex index dd7240e1..d6d5cc8e 100644 --- a/lib/philomena/images/thumbnailer.ex +++ b/lib/philomena/images/thumbnailer.ex @@ -5,6 +5,7 @@ defmodule Philomena.Images.Thumbnailer do alias Philomena.DuplicateReports alias Philomena.ImageIntensities + alias Philomena.ImagePurgeWorker alias Philomena.Images.Image alias Philomena.Processors alias Philomena.Analyzers @@ -103,8 +104,14 @@ defmodule Philomena.Images.Thumbnailer do defp apply_change(image, {:intensities, intensities}), do: ImageIntensities.create_image_intensity(image, intensities) - defp apply_change(image, {:replace_original, new_file}), - do: upload_file(image, new_file, "full.#{image.image_format}") + defp apply_change(image, {:replace_original, new_file}) do + 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}), do: Enum.map(thumbnails, &apply_thumbnail(image, &1))