fgerlits commented on a change in pull request #791:
URL: https://github.com/apache/nifi-minifi-cpp/pull/791#discussion_r428757113



##########
File path: extensions/standard-processors/processors/TailFile.cpp
##########
@@ -120,56 +158,42 @@ void TailFile::onSchedule(const 
std::shared_ptr<core::ProcessContext> &context,
   std::string value;
 
   if (context->getProperty(Delimiter.getName(), value)) {
-    delimiter_ = value;
+    delimiter_ = parseDelimiter(value);
+  }
+
+  if (!context->getProperty(FileName.getName(), file_to_tail_)) {
+    throw minifi::Exception(ExceptionType::PROCESSOR_EXCEPTION, "File to Tail 
is a required property");
   }
 
   std::string mode;
   context->getProperty(TailMode.getName(), mode);
 
-  std::string file = "";
-  if (!context->getProperty(FileName.getName(), file)) {
-    throw minifi::Exception(ExceptionType::PROCESSOR_EXCEPTION, "File to Tail 
is a required property");
-  }
   if (mode == "Multiple file") {
-    // file is a regex
-    std::string base_dir;
-    if (!context->getProperty(BaseDirectory.getName(), base_dir)) {
+    tail_mode_ = Mode::MULTIPLE;
+
+    if (!context->getProperty(BaseDirectory.getName(), base_dir_)) {
       throw minifi::Exception(ExceptionType::PROCESSOR_EXCEPTION, "Base 
directory is required for multiple tail mode.");
     }
 
-    auto fileRegexSelect = [&](const std::string& path, const std::string& 
filename) -> bool {
-      if (acceptFile(file, filename)) {
-        tail_states_.insert(std::make_pair(filename, TailState {path, 
filename, 0, 0}));
-      }
-      return true;
-    };
-
-    utils::file::FileUtils::list_dir(base_dir, fileRegexSelect, logger_, 
false);
+    // in multiple mode, we check for new/removed files in every onTrigger
 
   } else {
+    tail_mode_ = Mode::SINGLE;
+
     std::string fileLocation, fileName;
-    if (utils::file::PathUtils::getFileNameAndPath(file, fileLocation, 
fileName)) {
-      tail_states_.insert(std::make_pair(fileName, TailState { fileLocation, 
fileName, 0, 0 }));
+    if (utils::file::PathUtils::getFileNameAndPath(file_to_tail_, 
fileLocation, fileName)) {
+      tail_states_.emplace(fileName, TailState{fileLocation, fileName, 0, 0, 
0, 0});

Review comment:
       this will be overwritten in `recoverState()` if there is a persisted 
state, but I agree it looks misleading -- I'll think about how to make it 
clearer




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to