comparison OrthancServer/Sources/ServerContext.cpp @ 4500:3b4940bca158

added safeguards in Orthanc::FileInfo
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Feb 2021 14:49:30 +0100
parents 6f99949b2878
children 7d1eabfac6e0
comparison
equal deleted inserted replaced
4499:6f99949b2878 4500:3b4940bca158
569 // TODO Should we use "gzip" instead? 569 // TODO Should we use "gzip" instead?
570 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None); 570 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None);
571 571
572 FileInfo dicomInfo = accessor.Write(dicom.GetBufferData(), dicom.GetBufferSize(), 572 FileInfo dicomInfo = accessor.Write(dicom.GetBufferData(), dicom.GetBufferSize(),
573 FileContentType_Dicom, compression, storeMD5_); 573 FileContentType_Dicom, compression, storeMD5_);
574 FileInfo jsonInfo = accessor.Write(dicom.GetJson().toStyledString(),
575 FileContentType_DicomAsJson, compression, storeMD5_);
576 574
577 ServerIndex::Attachments attachments; 575 ServerIndex::Attachments attachments;
578 attachments.push_back(dicomInfo); 576 attachments.push_back(dicomInfo);
579 attachments.push_back(jsonInfo); 577
578 FileInfo jsonInfo;
579 if (true /* TODO - !area_.HasReadRange() || !hasPixelDataOffset */)
580 {
581 jsonInfo = accessor.Write(dicom.GetJson().toStyledString(),
582 FileContentType_DicomAsJson, compression, storeMD5_);
583 attachments.push_back(jsonInfo);
584 }
580 585
581 typedef std::map<MetadataType, std::string> InstanceMetadata; 586 typedef std::map<MetadataType, std::string> InstanceMetadata;
582 InstanceMetadata instanceMetadata; 587 InstanceMetadata instanceMetadata;
583 StoreStatus status = index_.Store( 588 StoreStatus status = index_.Store(
584 instanceMetadata, dicom, attachments, overwrite, hasPixelDataOffset, pixelDataOffset); 589 instanceMetadata, dicom, attachments, overwrite, hasPixelDataOffset, pixelDataOffset);
594 } 599 }
595 600
596 if (status != StoreStatus_Success) 601 if (status != StoreStatus_Success)
597 { 602 {
598 accessor.Remove(dicomInfo); 603 accessor.Remove(dicomInfo);
599 accessor.Remove(jsonInfo); 604
605 if (jsonInfo.IsValid())
606 {
607 accessor.Remove(jsonInfo);
608 }
600 } 609 }
601 610
602 switch (status) 611 switch (status)
603 { 612 {
604 case StoreStatus_Success: 613 case StoreStatus_Success: