Stopped worker from retrying if doing so wouldn't improve things (#210)

This commit is contained in:
Kieran
2024-04-29 14:06:12 -07:00
committed by GitHub
parent 09cac46e14
commit 3f74f199dc
2 changed files with 28 additions and 2 deletions
@@ -67,8 +67,8 @@ defmodule Pinchflat.Downloading.MediaDownloadWorker do
{:recovered, _} ->
{:error, :retry}
{:error, _message} ->
{:error, :download_failed}
{:error, message} ->
action_on_error(message)
end
end
@@ -89,4 +89,18 @@ defmodule Pinchflat.Downloading.MediaDownloadWorker do
nil
end
end
defp action_on_error(message) do
# This will attempt re-download at the next indexing, but it won't be retried
# immediately as part of job failure logic
non_retryable_errors = ["Video unavailable"]
if String.contains?(to_string(message), non_retryable_errors) do
Logger.error("yt-dlp download will not be retried: #{inspect(message)}")
{:ok, :non_retry}
else
{:error, :download_failed}
end
end
end