mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
Fix truncated images
This commit is contained in:
parent
aa0a5ffb48
commit
967afa064b
1 changed files with 13 additions and 3 deletions
|
@ -19,14 +19,24 @@ 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, status}} when status > 0 ->
|
||||
{^pid, {:exit_status, 0}} ->
|
||||
{:ok, acc}
|
||||
|
||||
{^pid, {:exit_status, status}} ->
|
||||
{:error, status}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue