rich media: parser: cache negatives
This commit is contained in:
parent
8fb16e9f0f
commit
83b7062634
@ -15,11 +15,13 @@ defmodule Pleroma.Web.RichMedia.Parser do
|
|||||||
def parse(url), do: parse_url(url)
|
def parse(url), do: parse_url(url)
|
||||||
else
|
else
|
||||||
def parse(url) do
|
def parse(url) do
|
||||||
with {:ok, data} <- Cachex.fetch(:rich_media_cache, url, fn _ -> parse_url(url) end) do
|
try do
|
||||||
data
|
Cachex.fetch!(:rich_media_cache, url, fn _ ->
|
||||||
else
|
{:commit, parse_url(url)}
|
||||||
_e ->
|
end)
|
||||||
{:error, "Parsing error"}
|
rescue
|
||||||
|
e ->
|
||||||
|
{:error, "Cachex error: #{inspect(e)}"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -30,8 +32,8 @@ defmodule Pleroma.Web.RichMedia.Parser do
|
|||||||
|
|
||||||
html |> maybe_parse() |> get_parsed_data()
|
html |> maybe_parse() |> get_parsed_data()
|
||||||
rescue
|
rescue
|
||||||
_e ->
|
e ->
|
||||||
{:error, "Parsing error"}
|
{:error, "Parsing error: #{inspect(e)}"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user