From 83b7062634d10bfa91adeb89bac10d854d6213d5 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 28 Jan 2019 20:19:07 +0000 Subject: [PATCH] rich media: parser: cache negatives --- lib/pleroma/web/rich_media/parser.ex | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/web/rich_media/parser.ex b/lib/pleroma/web/rich_media/parser.ex index bd21d2a0e..279e27273 100644 --- a/lib/pleroma/web/rich_media/parser.ex +++ b/lib/pleroma/web/rich_media/parser.ex @@ -15,11 +15,13 @@ defmodule Pleroma.Web.RichMedia.Parser do def parse(url), do: parse_url(url) else def parse(url) do - with {:ok, data} <- Cachex.fetch(:rich_media_cache, url, fn _ -> parse_url(url) end) do - data - else - _e -> - {:error, "Parsing error"} + try do + Cachex.fetch!(:rich_media_cache, url, fn _ -> + {:commit, parse_url(url)} + end) + rescue + e -> + {:error, "Cachex error: #{inspect(e)}"} end end end @@ -30,8 +32,8 @@ defmodule Pleroma.Web.RichMedia.Parser do html |> maybe_parse() |> get_parsed_data() rescue - _e -> - {:error, "Parsing error"} + e -> + {:error, "Parsing error: #{inspect(e)}"} end end -- 2.45.2