Check if mogrify available before calling it

This commit is contained in:
Roman Chvanikov 2020-07-11 18:22:03 +03:00
parent 523f1b93a4
commit 3116a75e80
2 changed files with 13 additions and 6 deletions

View file

@ -35,9 +35,12 @@ defmodule Pleroma.Upload.Filter.Mogrifun do
] ]
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
if Pleroma.Utils.command_available?("mogrify") do
Filter.Mogrify.do_filter(file, [Enum.random(@filters)]) Filter.Mogrify.do_filter(file, [Enum.random(@filters)])
:ok :ok
else
{:error, "mogrify command not found"}
end
end end
def filter(_), do: :ok def filter(_), do: :ok

View file

@ -9,10 +9,14 @@ defmodule Pleroma.Upload.Filter.Mogrify do
@type conversions :: conversion() | [conversion()] @type conversions :: conversion() | [conversion()]
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
if Pleroma.Utils.command_available?("mogrify") do
filters = Pleroma.Config.get!([__MODULE__, :args]) filters = Pleroma.Config.get!([__MODULE__, :args])
do_filter(file, filters) do_filter(file, filters)
:ok :ok
else
{:error, "mogrify command not found"}
end
end end
def filter(_), do: :ok def filter(_), do: :ok