diff Plugins/Engine/OrthancPluginDatabase.cpp @ 3105:2e1711f80f74 db-changes

More consistent handling of the "Last" field returned by the "/changes" URI
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 10 Jan 2019 18:02:34 +0100
parents b2b6db5ad9a5
children f86ebf971a72
line wrap: on
line diff
--- a/Plugins/Engine/OrthancPluginDatabase.cpp	Mon Jan 07 17:23:04 2019 +0100
+++ b/Plugins/Engine/OrthancPluginDatabase.cpp	Thu Jan 10 18:02:34 2019 +0100
@@ -278,6 +278,11 @@
     {
       LOG(WARNING) << "Performance warning in the database index: Some extensions are missing in the plugin";
     }
+
+    if (extensions_.getLastChangeIndex == NULL)
+    {
+      LOG(WARNING) << "The database extension GetLastChangeIndex() is missing";
+    }
   }
 
 
@@ -1392,4 +1397,21 @@
       ForwardAnswers(target);
     }
   }
+
+
+  int64_t OrthancPluginDatabase::GetLastChangeIndex()
+  {
+    if (extensions_.getLastChangeIndex == NULL)
+    {
+      // This was the default behavior in Orthanc <= 1.5.1
+      // https://groups.google.com/d/msg/orthanc-users/QhzB6vxYeZ0/YxabgqpfBAAJ
+      return 0;
+    }
+    else
+    {
+      int64_t result = 0;
+      CheckSuccess(extensions_.getLastChangeIndex(&result, payload_));
+      return result;
+    }
+  }
 }