Remove newline for linter
[akkoma] / lib / pleroma / helpers / media_helper.ex
index e11038052d6bd5df2c99c91617bf13cfd85901ac..89dd4204bdd6e7c9f508c03f111472a69cf6c5e6 100644 (file)
@@ -19,13 +19,22 @@ defmodule Pleroma.Helpers.MediaHelper do
     """
 
     pid = Port.open({:spawn, cmd}, [:use_stdio, :in, :stream, :exit_status, :binary])
+    loop_recv(pid)
+  end
+
+  defp loop_recv(pid) do
+    loop_recv(pid, <<>>)
+  end
 
+  defp loop_recv(pid, acc) do
     receive do
       {^pid, {:data, data}} ->
-        send(pid, {self(), :close})
-        {:ok, data}
+        loop_recv(pid, acc <> data)
+
+      {^pid, {:exit_status, 0}} ->
+        {:ok, acc}
 
-      {^pid, {:exit_status, status}} when status > 0 ->
+      {^pid, {:exit_status, status}} ->
         {:error, status}
     end
   end