changeset 4602:cfdd1f59ff6f db-changes

fix OrthancCDatabasePlugin.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 Mar 2021 19:25:27 +0100
parents 27c07dbf6b4f
children c125bfd31023
files OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp OrthancServer/Plugins/Include/orthanc/OrthancCDatabasePlugin.h OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp
diffstat 3 files changed, 26 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp	Fri Mar 19 10:52:22 2021 +0100
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp	Mon Mar 22 19:25:27 2021 +0100
@@ -725,9 +725,20 @@
                                 ResourceType& type,
                                 const std::string& publicId) ORTHANC_OVERRIDE
     {
-      CheckSuccess(that_.backend_.lookupResource(transaction_, Plugins::Convert(type), publicId.c_str()));
+      uint8_t existing;
+      OrthancPluginResourceType t;
+      CheckSuccess(that_.backend_.lookupResource(transaction_, &existing, &id, &t, publicId.c_str()));
       CheckNoEvent();
-      return ReadSingleInt64Answer(id);      
+
+      if (existing == 0)
+      {
+        return false;
+      }
+      else
+      {
+        type = Plugins::Convert(t);
+        return true;
+      }
     }
 
     
--- a/OrthancServer/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Fri Mar 19 10:52:22 2021 +0100
+++ b/OrthancServer/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Mon Mar 22 19:25:27 2021 +0100
@@ -1221,7 +1221,7 @@
                                                   uint8_t* target /* out */,
                                                   int64_t resourceId);
     
-    /* Answer is read using "readAnswerInt32()" */
+    /* Answers are read using "readAnswerInt32()" */
     OrthancPluginErrorCode (*listAvailableAttachments) (OrthancPluginDatabaseTransaction* transaction,
                                                         int64_t internalId);
 
@@ -1255,13 +1255,14 @@
                                               int64_t id,
                                               int32_t metadata);
     
-    /* Answer is read using "readAnswerInt64()" */
+    /* Answer is read using "readAnswerInt64()" -- TODO */
     OrthancPluginErrorCode (*lookupParent) (OrthancPluginDatabaseTransaction* transaction,
                                             int64_t id);
     
-    /* Answer is read using "readAnswerInt64()" */
     OrthancPluginErrorCode (*lookupResource) (OrthancPluginDatabaseTransaction* transaction,
-                                              OrthancPluginResourceType level,
+                                              uint8_t* isExisting /* out */,
+                                              int64_t* id /* out */,
+                                              OrthancPluginResourceType* type /* out */,
                                               const char* publicId);
     
     /* Answers are read using "readAnswerMatchingResource()" */
@@ -1279,10 +1280,10 @@
                                                        OrthancPluginResourceType* type /* out */,
                                                        const char* publicId);
 
-    /* Answer is read using "readAnswerInt64()" */
+    /* Answer is read using "readAnswerInt64()" -- TODO */
     OrthancPluginErrorCode (*selectPatientToRecycle) (OrthancPluginDatabaseTransaction* transaction);
     
-    /* Answer is read using "readAnswerInt64()" */
+    /* Answer is read using "readAnswerInt64()" -- TODO */
     OrthancPluginErrorCode (*selectPatientToRecycle2) (OrthancPluginDatabaseTransaction* transaction,
                                                        int64_t patientIdToAvoid);
 
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Fri Mar 19 10:52:22 2021 +0100
+++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Mon Mar 22 19:25:27 2021 +0100
@@ -2679,8 +2679,12 @@
       }
     };
 
-    Operations operations(maximumStorageSize, maximumPatientCount);
-    Apply(operations);
+    if (maximumStorageSize != 0 ||
+        maximumPatientCount != 0)
+    {
+      Operations operations(maximumStorageSize, maximumPatientCount);
+      Apply(operations);
+    }
   }