Consolidate the HTTP status code checking into the private get_object/1

This commit is contained in:
Mark Felder 2023-12-26 16:05:28 -05:00
parent d472bafec1
commit 67dd81e825
1 changed files with 4 additions and 9 deletions

View File

@ -99,15 +99,6 @@ def fetch_object_from_id(id, options \\ []) do
{:fetch_object, %Object{} = object} ->
{:ok, object}
{:fetch, {:error, {:ok, %Tesla.Env{status: 403}}}} ->
Instances.set_consistently_unreachable(id)
Logger.error(
"Error while fetching #{id}: HTTP 403 likely due to instance block rejecting the signed fetch."
)
{:error, "Object fetch has been denied"}
{:fetch, {:error, error}} ->
Logger.error("Error while fetching #{id}: #{inspect(error)}")
{:error, error}
@ -221,6 +212,10 @@ defp get_object(id) do
{:error, {:content_type, nil}}
end
{:ok, %{status: 403}} ->
Instances.set_consistently_unreachable(id)
{:error, "Object fetch has been denied"}
{:ok, %{status: code}} when code in [404, 410] ->
{:error, "Object has been deleted"}