changeset 5874:2701b450060c

fix failure when loading inexistent plugin
author Alain Mazy <am@orthanc.team>
date Tue, 19 Nov 2024 09:06:39 +0100
parents c8788f8f5322
children e08438a558b0
files OrthancServer/Plugins/Engine/PluginsManager.cpp
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/PluginsManager.cpp	Mon Nov 18 15:16:16 2024 +0100
+++ b/OrthancServer/Plugins/Engine/PluginsManager.cpp	Tue Nov 19 09:06:39 2024 +0100
@@ -244,7 +244,21 @@
   {
     if (!boost::filesystem::exists(path))
     {
-      throw OrthancException(ErrorCode_SharedLibrary, "Inexistent path to plugin: " + path);
+      boost::filesystem::path p(path);
+      std::string extension = p.extension().string();
+      Toolbox::ToLowerCase(extension);
+
+      if (extension == PLUGIN_EXTENSION)
+      { 
+        // if this is a plugin path, fail to start
+        throw OrthancException(ErrorCode_SharedLibrary, "Inexistent path to plugin: " + path);
+      }
+      else
+      { 
+        // it might be a directory -> just log a warning
+        LOG(WARNING) << "Inexistent path to plugins: " << path;
+        return;
+      }
     }
 
     if (boost::filesystem::is_directory(path))