fgerlits commented on code in PR #1428:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1428#discussion_r989212825


##########
extensions/sftp/processors/FetchSFTP.cpp:
##########
@@ -122,11 +122,11 @@ void FetchSFTP::onTrigger(const 
std::shared_ptr<core::ProcessContext> &context,
 
   /* Download file */
   try {
-    session->write(flow_file, [&remote_file, &client](const 
std::shared_ptr<io::BaseStream>& stream) -> int64_t {
+    session->write(flow_file, [&remote_file, &client, &flow_file](const 
std::shared_ptr<io::OutputStream>& stream) -> int64_t {
       if (!client->getFile(remote_file, *stream)) {
         throw utils::SFTPException{client->getLastError()};
       }
-      return gsl::narrow<int64_t>(stream->size());
+      return gsl::narrow<int64_t>(flow_file->getSize());

Review Comment:
   Are you sure this works?  The size of the flow file is set to 
`stream->size()` after the callback is invoked, so I'm not sure 
`flow_file->getSize()` is correct at this point.
   
   I would stick to the old logic of adding a virtual dummy `size()` 
implementation to `OutputStream`, and calling that here, relying on the runtime 
type being a `BufferStream`, which implements `size()` properly.
   
   A better solution could be if `client->getFile(...)` returned the number of 
bytes fetched, but that would probably be out of scope for this pull request.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to