Check if mogrify available before calling it
authorRoman Chvanikov <chvanikoff@pm.me>
Sat, 11 Jul 2020 15:22:03 +0000 (18:22 +0300)
committerRoman Chvanikov <chvanikoff@pm.me>
Sat, 11 Jul 2020 15:22:03 +0000 (18:22 +0300)
lib/pleroma/upload/filter/mogrifun.ex
lib/pleroma/upload/filter/mogrify.ex

index 7d95577a4a8029b1d941432de0ed35eb6dbf1136..8f362333d3867617faa82efd320b52f03c0d49a8 100644 (file)
@@ -35,9 +35,12 @@ defmodule Pleroma.Upload.Filter.Mogrifun do
   ]
 
   def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
-    Filter.Mogrify.do_filter(file, [Enum.random(@filters)])
-
-    :ok
+    if Pleroma.Utils.command_available?("mogrify") do
+      Filter.Mogrify.do_filter(file, [Enum.random(@filters)])
+      :ok
+    else
+      {:error, "mogrify command not found"}
+    end
   end
 
   def filter(_), do: :ok
index 2eb75800659993110500e8d38e1f1abc907fae92..4bd0c2eb449b3c05804d69b916e8199945336495 100644 (file)
@@ -9,10 +9,14 @@ defmodule Pleroma.Upload.Filter.Mogrify do
   @type conversions :: conversion() | [conversion()]
 
   def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
-    filters = Pleroma.Config.get!([__MODULE__, :args])
-
-    do_filter(file, filters)
-    :ok
+    if Pleroma.Utils.command_available?("mogrify") do
+      filters = Pleroma.Config.get!([__MODULE__, :args])
+
+      do_filter(file, filters)
+      :ok
+    else
+      {:error, "mogrify command not found"}
+    end
   end
 
   def filter(_), do: :ok