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


##########
core-framework/include/utils/Locations.h:
##########
@@ -0,0 +1,41 @@
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <filesystem>
+
+#include "Environment.h"
+#include "file/FileUtils.h"
+#include "Defaults.h"
+
+namespace org::apache::nifi::minifi::utils {
+inline std::string getDefaultExtensionsPattern() {
+  constexpr std::string_view DEFAULT_EXTENSION_PATH = "../extensions/*";
+  constexpr std::string_view DEFAULT_EXTENSION_PATH_RPM = RPM_LIB_DIR 
"/extensions/*";
+  if 
(Environment::getEnvironmentVariable(std::string(MINIFI_HOME_ENV_KEY).c_str()) 
== MINIFI_HOME_ENV_VALUE_FHS || file::get_executable_path().parent_path() == 
"/usr/bin") {
+    return std::string(DEFAULT_EXTENSION_PATH_RPM);
+  }
+  return std::string(DEFAULT_EXTENSION_PATH);
+}
+
+inline std::filesystem::path getMinifiDir() {
+  if 
(Environment::getEnvironmentVariable(std::string(MINIFI_HOME_ENV_KEY).c_str()) 
== MINIFI_HOME_ENV_VALUE_FHS || file::get_executable_path().parent_path() == 
"/usr/bin") {
+    return RPM_WORK_DIR;
+  }
+  return 
Environment::getEnvironmentVariable(std::string(MINIFI_HOME_ENV_KEY).c_str()).value_or("");
+}

Review Comment:
   Sadly there are a couple of places where we falled back to the path set in 
the configuration. like
   `  if 
(configuration->get(Configure::nifi_dbcontent_repository_directory_default, 
value) && !value.empty()) {
       directory_ = value;
     } else {
       directory_ = (configuration->getHome() / "dbcontentrepository").string();
     }
   `
   
   Which is probably set to minifi_home (but it very well could be empty if the 
config is not THE config)
   
https://github.com/apache/nifi-minifi-cpp/blob/main/minifi_main/MiNiFiMain.cpp#L334
   
   Now after the MainHelper runs non rpm mode, we set the MINIFI_HOME_ENV_KEY 
to the determined minifi_home so we can check the env var to determine without 
needing the config.
   
   (and in RPM mode we know where the working dir should be so we return that)



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