martinzink commented on code in PR #1634:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1634#discussion_r1320125791


##########
extensions/standard-processors/processors/PutFile.cpp:
##########
@@ -61,132 +54,91 @@ void PutFile::onSchedule(core::ProcessContext *context, 
core::ProcessSessionFact
 #endif
 }
 
-void PutFile::onTrigger(core::ProcessContext *context, core::ProcessSession 
*session) {
-  if (IsNullOrEmpty(conflict_resolution_)) {
-    logger_->log_error("Conflict resolution value is invalid");
-    context->yield();
-    return;
-  }
-
-  std::shared_ptr<core::FlowFile> flowFile = session->get();
-
-  // Do nothing if there are no incoming files
-  if (!flowFile) {
-    return;
-  }
-
-  session->remove(flowFile);
-
+std::optional<std::filesystem::path> 
PutFile::getDestinationPath(core::ProcessContext& context, const 
std::shared_ptr<core::FlowFile>& flow_file) {
   std::filesystem::path directory;
-
-  if (auto directory_str = context->getProperty(Directory, flowFile)) {
+  if (auto directory_str = context.getProperty(Directory, flow_file); 
directory_str && !directory_str->empty()) {
     directory = *directory_str;
   } else {
-    logger_->log_error("Directory attribute is missing or invalid");
-  }
-
-  if (IsNullOrEmpty(directory)) {
     logger_->log_error("Directory attribute evaluated to invalid value");
-    session->transfer(flowFile, Failure);
-    return;
+    return std::nullopt;
   }
+  auto file_name_str = 
flow_file->getAttribute(core::SpecialFlowAttribute::FILENAME).value_or(flow_file->getUUIDStr());
 
-  std::string filename;
-  flowFile->getAttribute(core::SpecialFlowAttribute::FILENAME, filename);
-  auto tmpFile = tmpWritePath(filename, directory);
-
-  logger_->log_debug("PutFile using temporary file %s", tmpFile.string());
+  return directory / file_name_str;
+}
 
-  // Determine dest full file paths
-  auto destFile = directory / filename;
+bool PutFile::directoryIsFull(const std::filesystem::path& directory) const {
+  return max_dest_files_ && utils::file::is_directory(directory) && 
utils::file::countNumberOfFiles(directory) >= *max_dest_files_;

Review Comment:
   checking the is_directory inside getDestinationPath premature failed the 
cases when we later want to create the output directory if its missing.
   But it turns out we dont need this here, so i simply removed it from here. 
https://github.com/apache/nifi-minifi-cpp/pull/1634/commits/3b513dcd2120d5e5ab361e8230060721450c6551#diff-4299528914a07e18b8a6ce5fc7f6847e873b664e0d179f40fa429ff167afd116L71



-- 
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