25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Correctly calculate remaining bytes on file upload

This commit is contained in:
Evgeniy Khramtsov 2018-05-19 18:29:33 +03:00
parent db51d522e8
commit d2114be6f3

View File

@ -617,7 +617,7 @@ do_recv_file(Len, SockMod, Socket, Fd) ->
try try
{ok, Data} = SockMod:recv(Socket, ChunkLen, timer:seconds(30)), {ok, Data} = SockMod:recv(Socket, ChunkLen, timer:seconds(30)),
ok = file:write(Fd, Data), ok = file:write(Fd, Data),
do_recv_file(Len-ChunkLen, SockMod, Socket, Fd) do_recv_file(Len-size(Data), SockMod, Socket, Fd)
catch _:{badmatch, {error, _} = Err} -> catch _:{badmatch, {error, _} = Err} ->
file:close(Fd), file:close(Fd),
Err Err