Keep args construction within video/image scopes instead of mangling down in fifo town
This commit is contained in:
parent
dd1de994d5
commit
3a5231ec8f
|
@ -16,6 +16,7 @@ def image_resize(url, options) do
|
||||||
{:ok, env} <- Pleroma.HTTP.get(url),
|
{:ok, env} <- Pleroma.HTTP.get(url),
|
||||||
{:ok, fifo_path} <- mkfifo()
|
{:ok, fifo_path} <- mkfifo()
|
||||||
do
|
do
|
||||||
|
args = List.flatten([fifo_path, args])
|
||||||
run_fifo(fifo_path, env, executable, args)
|
run_fifo(fifo_path, env, executable, args)
|
||||||
else
|
else
|
||||||
nil -> {:error, {:convert, :command_not_found}}
|
nil -> {:error, {:convert, :command_not_found}}
|
||||||
|
@ -58,12 +59,6 @@ def video_framegrab(url) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp run_fifo(fifo_path, env, executable, args) do
|
defp run_fifo(fifo_path, env, executable, args) do
|
||||||
args =
|
|
||||||
if _executable = System.find_executable("convert") do
|
|
||||||
List.flatten([fifo_path, args])
|
|
||||||
else
|
|
||||||
args
|
|
||||||
end
|
|
||||||
pid = Port.open({:spawn_executable, executable}, [:use_stdio, :stream, :exit_status, :binary, args: args])
|
pid = Port.open({:spawn_executable, executable}, [:use_stdio, :stream, :exit_status, :binary, args: args])
|
||||||
fifo = Port.open(to_charlist(fifo_path), [:eof, :binary, :stream, :out])
|
fifo = Port.open(to_charlist(fifo_path), [:eof, :binary, :stream, :out])
|
||||||
true = Port.command(fifo, env.body)
|
true = Port.command(fifo, env.body)
|
||||||
|
|
Loading…
Reference in New Issue