changeset 4:da409b29cc02

by default, put the indexer database next to the orthanc database
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 23 Sep 2021 13:14:31 +0200
parents e731f308b8b1
children f76fdef338a3
files Sources/Plugin.cpp
diffstat 1 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Sources/Plugin.cpp	Mon Sep 20 17:15:21 2021 +0200
+++ b/Sources/Plugin.cpp	Thu Sep 23 13:14:31 2021 +0200
@@ -473,8 +473,11 @@
     {
       try
       {
+        static const char* const DATABASE = "Database";
         static const char* const FOLDERS = "Folders";
-        static const char* const DATABASE = "Database";
+        static const char* const INDEX_DIRECTORY = "IndexDirectory";
+        static const char* const ORTHANC_STORAGE = "OrthancStorage";
+        static const char* const STORAGE_DIRECTORY = "StorageDirectory";
 
         if (!indexer.LookupListOfStrings(folders_, FOLDERS, true) ||
             folders_.empty())
@@ -483,11 +486,22 @@
                                           "Missing configuration option for Indexer plugin: " + std::string(FOLDERS));
         }
 
-        const std::string path = indexer.GetStringValue(DATABASE, "indexer.db");
-        LOG(INFO) << "Path to the database of the Indexer plugin: " << path;
+        std::string path;
+        if (!indexer.LookupStringValue(path, DATABASE))
+        {
+          std::string folder;
+          if (!configuration.LookupStringValue(folder, INDEX_DIRECTORY))
+          {
+            folder = configuration.GetStringValue(STORAGE_DIRECTORY, ORTHANC_STORAGE);
+          }
+
+          path = (boost::filesystem::path(folder) / "indexer.db").string();
+        }
+        
+        LOG(WARNING) << "Path to the database of the Indexer plugin: " << path;
         database_.Open(path);
 
-        storageArea_.reset(new StorageArea(configuration.GetStringValue("StorageDirectory", "OrthancStorage")));
+        storageArea_.reset(new StorageArea(configuration.GetStringValue(STORAGE_DIRECTORY, ORTHANC_STORAGE)));
       }
       catch (Orthanc::OrthancException& e)
       {