# HG changeset patch # User Alain Mazy # Date 1674231875 -3600 # Node ID b2b38f9fb9d12c26ca6453b68572bb93ea4ad4e5 # Parent 021d7fdcb65944271e7ff2e1dc28a39dbde9fa21# Parent d00db9fb48fb0f49555fc484ea0bc63e37b41cb0 merge diff -r d00db9fb48fb -r b2b38f9fb9d1 OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp --- 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)