changeset 6130:31d41a52ac2f attach-custom-data

db capabilities
author Alain Mazy <am@orthanc.team>
date Wed, 21 May 2025 21:29:52 +0200
parents e919f8d24f09
children 24bf08f02e55
files OrthancFramework/Sources/Toolbox.cpp OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp
diffstat 4 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/Toolbox.cpp	Wed May 21 21:29:18 2025 +0200
+++ b/OrthancFramework/Sources/Toolbox.cpp	Wed May 21 21:29:52 2025 +0200
@@ -499,6 +499,40 @@
   }
 
   void Toolbox::ComputeMD5(std::string& result,
+                           std::istream& inputStream)
+  {
+    md5_state_s state;
+    md5_init(&state);
+
+    const size_t bufferSize = 1024;
+    char buffer[bufferSize];
+    
+    while (inputStream.good())
+    {
+      inputStream.read(buffer, bufferSize);
+      std::streamsize bytesRead = inputStream.gcount();
+
+      if (bytesRead > 0)
+      {
+        md5_append(&state, 
+                   reinterpret_cast<const md5_byte_t*>(buffer), 
+                 static_cast<int>(bytesRead));
+      }
+    }
+
+    md5_byte_t actualHash[16];
+    md5_finish(&state, actualHash);
+
+    result.resize(32);
+    for (unsigned int i = 0; i < 16; i++)
+    {
+      result[2 * i] = GetHexadecimalCharacter(static_cast<uint8_t>(actualHash[i] / 16));
+      result[2 * i + 1] = GetHexadecimalCharacter(static_cast<uint8_t>(actualHash[i] % 16));
+    }
+  }
+
+
+  void Toolbox::ComputeMD5(std::string& result,
                            const std::set<std::string>& data)
   {
     std::string s;
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp	Wed May 21 21:29:18 2025 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp	Wed May 21 21:29:52 2025 +0200
@@ -2128,6 +2128,7 @@
       dbCapabilities_.SetHasFindSupport(systemInfo.supports_find());
       dbCapabilities_.SetKeyValueStoresSupport(systemInfo.supports_key_value_stores());
       dbCapabilities_.SetQueuesSupport(systemInfo.supports_queues());
+      dbCapabilities_.SetAttachmentCustomDataSupport(systemInfo.has_attachment_custom_data());
     }
 
     open_ = true;
--- a/OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto	Wed May 21 21:29:18 2025 +0200
+++ b/OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto	Wed May 21 21:29:52 2025 +0200
@@ -174,6 +174,7 @@
     bool has_extended_changes = 9;  // New in Orthanc 1.12.5
     bool supports_key_value_stores = 10;  // New in Orthanc 1.12.99
     bool supports_queues = 11;            // New in Orthanc 1.12.99
+    bool has_attachment_custom_data = 12; // New in Orthanc 1.12.99
   }
 }
 
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Wed May 21 21:29:18 2025 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Wed May 21 21:29:52 2025 +0200
@@ -2516,6 +2516,7 @@
     dbCapabilities_.SetHasFindSupport(HasIntegratedFind());
     dbCapabilities_.SetKeyValueStoresSupport(true);
     dbCapabilities_.SetQueuesSupport(true);
+    dbCapabilities_.SetAttachmentCustomDataSupport(true);
     db_.Open(path);
   }
 
@@ -2532,6 +2533,7 @@
     dbCapabilities_.SetHasFindSupport(HasIntegratedFind());
     dbCapabilities_.SetKeyValueStoresSupport(true);
     dbCapabilities_.SetQueuesSupport(true);
+    dbCapabilities_.SetAttachmentCustomDataSupport(true);
     db_.OpenInMemory();
   }