# HG changeset patch # User Alain Mazy # Date 1674231856 -3600 # Node ID 021d7fdcb65944271e7ff2e1dc28a39dbde9fa21 # Parent 15109c3f0f7d2be0a5623d92f7e442057d194968 more sanity checks for modifications diff -r 15109c3f0f7d -r 021d7fdcb659 OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp --- a/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp Wed Jan 18 17:58:51 2023 +0100 +++ b/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp Fri Jan 20 17:24:16 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)