From 66f17c93c223766349d9ac59f00468160901adfb Mon Sep 17 00:00:00 2001 From: ChristianVisintin Date: Thu, 10 Dec 2020 11:27:00 +0100 Subject: [PATCH] Finalize get stream for FTP --- src/filetransfer/ftp_transfer.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/filetransfer/ftp_transfer.rs b/src/filetransfer/ftp_transfer.rs index 6428953..16809d5 100644 --- a/src/filetransfer/ftp_transfer.rs +++ b/src/filetransfer/ftp_transfer.rs @@ -574,8 +574,19 @@ impl FileTransfer for FtpFileTransfer { /// The purpose of this method is to finalize the connection with the peer when reading data. /// This mighe be necessary for some protocols. /// You must call this method each time you want to finalize the read of the remote file. - fn on_recv(&mut self, _readable: Box) -> Result<(), FileTransferError> { - Ok(()) + fn on_recv(&mut self, readable: Box) -> Result<(), FileTransferError> { + match &mut self.stream { + Some(stream) => match stream.finalize_get(readable) { + Ok(_) => Ok(()), + Err(err) => Err(FileTransferError::new_ex( + FileTransferErrorType::ProtocolError, + format!("{}", err), + )), + }, + None => Err(FileTransferError::new( + FileTransferErrorType::UninitializedSession, + )), + } } }