Adjusted MediaProxyControllerTest to gracefully fail on missing dependencies. Installation docs update.

Added ffmpeg/imagemagick checks to launch checks (if media preview proxy is enabled). Added documentation on installing optional media / graphics packages (imagemagick, ffmpeg, exiftool).
This commit is contained in:
Ivan Tashkinov 2020-09-26 19:32:16 +03:00
commit 4e4f771082
14 changed files with 180 additions and 27 deletions

View file

@ -268,7 +268,8 @@ defmodule Pleroma.Application do
with true <- filter in filters,
false <- Pleroma.Utils.command_available?(command_required) do
Logger.error(
"#{filter} is specified in list of Pleroma.Upload filters, but the #{command_required} command is not found"
"#{filter} is specified in list of Pleroma.Upload filters, but the " <>
"#{command_required} command is not found"
)
end
end
@ -276,5 +277,20 @@ defmodule Pleroma.Application do
check_filter.(Pleroma.Upload.Filters.Exiftool, "exiftool")
check_filter.(Pleroma.Upload.Filters.Mogrify, "mogrify")
check_filter.(Pleroma.Upload.Filters.Mogrifun, "mogrify")
with true <- Config.get([:media_preview_proxy, :enabled]),
missing_graphics_tools = Pleroma.Helpers.MediaHelper.missing_dependencies(),
[] <- missing_graphics_tools do
:noop
else
false ->
:noop
missing_graphics_tools ->
Logger.error(
"The following dependencies required by Media preview proxy " <>
"(which is currently enabled) are not installed: #{inspect(missing_graphics_tools)}"
)
end
end
end

View file

@ -9,6 +9,18 @@ defmodule Pleroma.Helpers.MediaHelper do
alias Pleroma.HTTP
require Logger
def missing_dependencies do
Enum.reduce([imagemagick: "convert", ffmpeg: "ffmpeg"], [], fn {sym, executable}, acc ->
if Pleroma.Utils.command_available?(executable) do
acc
else
[sym | acc]
end
end)
end
def image_resize(url, options) do
with executable when is_binary(executable) <- System.find_executable("convert"),
{:ok, args} <- prepare_image_resize_args(options),