File 3206-ftp-Deliver-already-recived-data.patch of Package erlang
From 7662aa4e2ef041f7b2896b8a85cf77c2ad549abd Mon Sep 17 00:00:00 2001
From: Ingela Anderton Andin <ingela@erlang.org>
Date: Mon, 19 Oct 2020 12:40:20 +0200
Subject: [PATCH 6/6] ftp: Deliver already recived data
---
lib/ftp/src/ftp.erl | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/lib/ftp/src/ftp.erl b/lib/ftp/src/ftp.erl
index 3941e695f2..53e9976c96 100644
--- a/lib/ftp/src/ftp.erl
+++ b/lib/ftp/src/ftp.erl
@@ -1097,7 +1097,6 @@ handle_call({_,{type, Type}}, From, #state{chunk = false} = State0) ->
_ ->
{reply, {error, etype}, State0}
end;
-
handle_call({_,{recv, RemoteFile, LocalFile}}, From,
#state{chunk = false, ldir = LocalDir} = State) ->
progress_report({remote_file, RemoteFile}, State),
@@ -1112,12 +1111,10 @@ handle_call({_,{recv, RemoteFile, LocalFile}}, From,
{error, _What} ->
{reply, {error, epath}, State}
end;
-
handle_call({_, {recv_bin, RemoteFile}}, From, #state{chunk = false} =
State) ->
setup_data_connection(State#state{caller = {recv_bin, RemoteFile},
client = From});
-
handle_call({_,{recv_chunk_start, RemoteFile}}, From, #state{chunk = false}
= State) ->
setup_data_connection(State#state{caller = {start_chunk_transfer,
@@ -1126,7 +1123,21 @@ handle_call({_,{recv_chunk_start, RemoteFile}}, From, #state{chunk = false}
handle_call({_, recv_chunk}, _, #state{chunk = false} = State) ->
{reply, {error, "ftp:recv_chunk_start/2 not called"}, State};
-
+handle_call({_, recv_chunk}, _From, #state{chunk = true,
+ data = Bin,
+ caller = #recv_chunk_closing{dconn_closed = true,
+ pos_compl_received = true,
+ client_called_us = true
+ }
+ } = State0) ->
+ case Bin of
+ <<>> ->
+ {reply, ok, State0#state{caller = undefined,
+ chunk = false,
+ client = undefined}};
+ Data ->
+ {reply, Data, State0}
+ end;
handle_call({_, recv_chunk}, _From, #state{chunk = true,
caller = #recv_chunk_closing{dconn_closed = true,
pos_compl_received = true
--
2.26.2