comparison OrthancServer/Sources/ServerContext.cpp @ 5464:38f1d06875ad pg-transactions

delete attachment in case of same instance being uploaded multiple times at the same time
author Alain Mazy <am@osimis.io>
date Tue, 12 Dec 2023 17:20:10 +0100
parents 9ffd6d18daf3
children 4dd50c4b985a
comparison
equal deleted inserted replaced
5459:46ed738c3e5d 5464:38f1d06875ad
708 attachments.push_back(dicomUntilPixelData); 708 attachments.push_back(dicomUntilPixelData);
709 } 709 }
710 710
711 typedef std::map<MetadataType, std::string> InstanceMetadata; 711 typedef std::map<MetadataType, std::string> InstanceMetadata;
712 InstanceMetadata instanceMetadata; 712 InstanceMetadata instanceMetadata;
713 result.SetStatus(index_.Store( 713
714 instanceMetadata, summary, attachments, dicom.GetMetadata(), dicom.GetOrigin(), overwrite, 714 try
715 hasTransferSyntax, transferSyntax, hasPixelDataOffset, pixelDataOffset, pixelDataVR, isReconstruct)); 715 {
716 result.SetStatus(index_.Store(
717 instanceMetadata, summary, attachments, dicom.GetMetadata(), dicom.GetOrigin(), overwrite,
718 hasTransferSyntax, transferSyntax, hasPixelDataOffset, pixelDataOffset, pixelDataVR, isReconstruct));
719 }
720 catch (OrthancException& ex)
721 {
722 if (ex.GetErrorCode() == ErrorCode_DuplicateResource)
723 {
724 LOG(WARNING) << "Duplicate instance, deleting the attachments";
725
726 accessor.Remove(dicomInfo);
727
728 if (dicomUntilPixelData.IsValid())
729 {
730 accessor.Remove(dicomUntilPixelData);
731 }
732
733 throw;
734 }
735 }
716 736
717 // Only keep the metadata for the "instance" level 737 // Only keep the metadata for the "instance" level
718 dicom.ClearMetadata(); 738 dicom.ClearMetadata();
719 739
720 for (InstanceMetadata::const_iterator it = instanceMetadata.begin(); 740 for (InstanceMetadata::const_iterator it = instanceMetadata.begin();