diff OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp @ 5009:ed4ceb31bcf8

Housekeeper plugin: Fix resume of previous processing
author Alain Mazy <am@osimis.io>
date Tue, 24 May 2022 14:47:51 +0200
parents 8feb00fea93d
children 67d98fccc850
line wrap: on
line diff
--- a/OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp	Tue May 24 14:47:35 2022 +0200
+++ b/OrthancServer/Plugins/Samples/Housekeeper/Plugin.cpp	Tue May 24 14:47:51 2022 +0200
@@ -537,21 +537,37 @@
 
   bool needsReconstruct = false;
   bool needsReingest = false;
+  bool needsFullProcessing = false;
+  bool needsProcessing = false;
 
   {
     boost::recursive_mutex::scoped_lock lock(pluginStatusMutex_);
+
+    // compare with last full processed configuration
     CheckNeedsProcessing(needsReconstruct, needsReingest, currentDbConfiguration, pluginStatus_.lastProcessedConfiguration);
+    needsFullProcessing = needsReconstruct || needsReingest;
+    needsProcessing = needsFullProcessing;
+
+      // if a processing was in progress, check if the config has changed since
+    if (pluginStatus_.currentlyProcessingConfiguration.IsDefined())
+    {
+      needsProcessing = true;       // since a processing was in progress, we need at least a partial processing
+
+      bool needsReconstruct2 = false;
+      bool needsReingest2 = false;
+
+      CheckNeedsProcessing(needsReconstruct2, needsReingest2, currentDbConfiguration, pluginStatus_.currentlyProcessingConfiguration);
+      needsFullProcessing = needsReconstruct2 || needsReingest2;  // if the configuration has changed compared to the config being processed, we need a full processing again
+    }
   }
 
-  bool needsProcessing = needsReconstruct || needsReingest;
-
   if (!needsProcessing)
   {
     OrthancPlugins::LogWarning("Housekeeper: everything has been processed already !");
     return;
   }
 
-  if (force_ || needsProcessing)
+  if (force_ || needsFullProcessing)
   {
     if (force_)
     {