From 5a62868106465bd30be11922b4ff3b11b3c174aa Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Wed, 24 Jul 2024 15:43:45 -0400 Subject: [PATCH] Consider errors during HTTP GET and HEAD to be unrecoverable and insert a negative cache entry This is for a normal HTTP error response or timeout while receiving the data. A hard error from a process crash, DNS lookup failure, etc should produce a different response than {:ok, %Tesla.Env{}} and the request/job will be retryable. --- lib/pleroma/web/rich_media/backfill.ex | 6 +----- lib/pleroma/workers/rich_media_worker.ex | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/pleroma/web/rich_media/backfill.ex b/lib/pleroma/web/rich_media/backfill.ex index a66422e71..cf638fa29 100644 --- a/lib/pleroma/web/rich_media/backfill.ex +++ b/lib/pleroma/web/rich_media/backfill.ex @@ -36,13 +36,9 @@ def run(%{"url" => url} = args) do :ok {:error, type} = error - when type in [:invalid_metadata, :body_too_large, :content_type, :validate] -> + when type in [:invalid_metadata, :body_too_large, :content_type, :validate, :get, :head] -> negative_cache(url_hash) error - - {:error, type} = error - when type in [:get, :head] -> - error end end diff --git a/lib/pleroma/workers/rich_media_worker.ex b/lib/pleroma/workers/rich_media_worker.ex index 0a1c6d58c..2ebf42d4f 100644 --- a/lib/pleroma/workers/rich_media_worker.ex +++ b/lib/pleroma/workers/rich_media_worker.ex @@ -20,13 +20,9 @@ def perform(%Job{args: %{"op" => "backfill", "url" => _url} = args}) do :ok {:error, type} - when type in [:invalid_metadata, :body_too_large, :content_type, :validate] -> + when type in [:invalid_metadata, :body_too_large, :content_type, :validate, :get, :head] -> {:cancel, type} - {:error, type} - when type in [:get, :head] -> - {:error, type} - error -> {:error, error} end