changeset 5140:b2b38f9fb9d1

merge
author Alain Mazy <am@osimis.io>
date Fri, 20 Jan 2023 17:24:35 +0100
parents 021d7fdcb659 (diff) d00db9fb48fb (current diff)
children 023569e7155b
files
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp	Thu Jan 19 19:04:13 2023 +0100
+++ b/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp	Fri Jan 20 17:24:35 2023 +0100
@@ -669,11 +669,24 @@
       replaceInstanceMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Instance);
     }
 
-    if (modification_->IsKept(DICOM_TAG_SOP_INSTANCE_UID) && !IsKeepSource())
+    if (modification_->IsKept(DICOM_TAG_SOP_INSTANCE_UID) 
+        && (modificationLevel == ResourceType_Series || modificationLevel == ResourceType_Study || modificationLevel == ResourceType_Patient))
     {
-      // note: we could refine this criteria -> this is valid only if all DicomUIDs are kept identical (but this can happen through Keep or Replace options)
-      throw OrthancException(ErrorCode_BadRequest,
-                             "When keeping SOPInstanceUID tag, you must set KeepSource to true to avoid deleting the modified files at the end of the process");
+      // if we keep the SOPInstanceUID, it very likely means that we are modifying existing resources 'in place'
+
+      // we must make sure we do not delete them at the end of the job
+      if (!IsKeepSource()) // note: we can refine this criteria -> this is valid only if all DicomUIDs are kept identical (but this can happen through Keep or Replace options)
+      {
+        throw OrthancException(ErrorCode_BadRequest,
+                              "When keeping SOPInstanceUID tag, you must set KeepSource to true to avoid deleting the modified files at the end of the process");
+      }
+
+      // and we must make sure that we overwite them with the modified resources
+      if (IsKeepSource() && !GetContext().IsOverwriteInstances())
+      {
+        throw OrthancException(ErrorCode_BadRequest,
+                              "When keeping SOPInstanceUID tag, you must have the 'OverwriteInstances' Orthanc configuration set to true in order to replace the modified resources");
+      }
     }
 
     if (modificationLevel == ResourceType_Study && replacePatientMainDicomTags)