[GitHub] [nifi-minifi-cpp] martinzink commented on a change in pull request #1181: MINIFICPP-1650: ProcessSession::append sets the flowfile size
martinzink commented on a change in pull request #1181: URL: https://github.com/apache/nifi-minifi-cpp/pull/1181#discussion_r719129867 ## File path: libminifi/src/core/ProcessSession.cpp ## @@ -269,14 +269,15 @@ void ProcessSession::append(const std::shared_ptr &flow, OutputS } // Call the callback to write the content -size_t oldPos = stream->size(); +size_t flow_file_size = flow->getSize(); +size_t stream_size_before_callback = stream->size(); // this prevents an issue if we write, above, with zero length. -if (oldPos > 0) - stream->seek(oldPos + 1); +if (stream_size_before_callback > 0) + stream->seek(stream_size_before_callback + 1); if (callback->process(stream) < 0) { throw Exception(FILE_OPERATION_EXCEPTION, "Failed to process flowfile content"); } -flow->setSize(stream->size()); +flow->setSize(flow_file_size - stream_size_before_callback + stream->size()); Review comment: The problem was that ContentSession::write with WriteMode::APPEND can give back a new stream which it will merge with the original stream later. However the flowfile size is only changed here. -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [nifi-minifi-cpp] martinzink commented on a change in pull request #1181: MINIFICPP-1650: ProcessSession::append sets the flowfile size
martinzink commented on a change in pull request #1181: URL: https://github.com/apache/nifi-minifi-cpp/pull/1181#discussion_r719129867 ## File path: libminifi/src/core/ProcessSession.cpp ## @@ -269,14 +269,15 @@ void ProcessSession::append(const std::shared_ptr &flow, OutputS } // Call the callback to write the content -size_t oldPos = stream->size(); +size_t flow_file_size = flow->getSize(); +size_t stream_size_before_callback = stream->size(); // this prevents an issue if we write, above, with zero length. -if (oldPos > 0) - stream->seek(oldPos + 1); +if (stream_size_before_callback > 0) + stream->seek(stream_size_before_callback + 1); if (callback->process(stream) < 0) { throw Exception(FILE_OPERATION_EXCEPTION, "Failed to process flowfile content"); } -flow->setSize(stream->size()); +flow->setSize(flow_file_size - stream_size_before_callback + stream->size()); Review comment: The problem was that ContentSession::write with WriteMode::APPEND can give back a new stream which it will merge with the original stream later. (see ContentSession::extendedResources_) However the flowfile size is only changed here. So appending to the flowfile overwrote the size with the appended content's size. -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [nifi-minifi-cpp] martinzink commented on a change in pull request #1181: MINIFICPP-1650: ProcessSession::append sets the flowfile size
martinzink commented on a change in pull request #1181: URL: https://github.com/apache/nifi-minifi-cpp/pull/1181#discussion_r719196114 ## File path: libminifi/src/core/ProcessSession.cpp ## @@ -269,14 +269,15 @@ void ProcessSession::append(const std::shared_ptr &flow, OutputS } // Call the callback to write the content -size_t oldPos = stream->size(); +size_t flow_file_size = flow->getSize(); +size_t stream_size_before_callback = stream->size(); // this prevents an issue if we write, above, with zero length. -if (oldPos > 0) - stream->seek(oldPos + 1); +if (stream_size_before_callback > 0) + stream->seek(stream_size_before_callback + 1); if (callback->process(stream) < 0) { throw Exception(FILE_OPERATION_EXCEPTION, "Failed to process flowfile content"); } -flow->setSize(stream->size()); +flow->setSize(flow_file_size - stream_size_before_callback + stream->size()); Review comment: good idea, changed it in https://github.com/apache/nifi-minifi-cpp/pull/1181/commits/4debe9813863f259af20e6919a8521b5ef97d28c -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org