comparison OrthancServer/Sources/ServerContext.cpp @ 4519:a3c6678aa7b1

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 Feb 2021 16:51:23 +0100
parents 5b929e6b3c36
children f75c63aa9de0
comparison
equal deleted inserted replaced
4518:cb8fcecf1b02 4519:a3c6678aa7b1
584 attachments.push_back(dicomInfo); 584 attachments.push_back(dicomInfo);
585 585
586 FileInfo dicomUntilPixelData; 586 FileInfo dicomUntilPixelData;
587 if (hasPixelDataOffset && 587 if (hasPixelDataOffset &&
588 (!area_.HasReadRange() || 588 (!area_.HasReadRange() ||
589 compression != CompressionType_None)) 589 compressionEnabled_))
590 { 590 {
591 dicomUntilPixelData = accessor.Write(dicom.GetBufferData(), pixelDataOffset, 591 dicomUntilPixelData = accessor.Write(dicom.GetBufferData(), pixelDataOffset,
592 FileContentType_DicomUntilPixelData, compression, storeMD5_); 592 FileContentType_DicomUntilPixelData, compression, storeMD5_);
593 attachments.push_back(dicomUntilPixelData); 593 attachments.push_back(dicomUntilPixelData);
594 } 594 }
854 * attachment. Lookup whether the pixel data offset has already 854 * attachment. Lookup whether the pixel data offset has already
855 * been computed for this instance. 855 * been computed for this instance.
856 **/ 856 **/
857 857
858 bool hasPixelDataOffset; 858 bool hasPixelDataOffset;
859 uint64_t pixelDataOffset; 859 uint64_t pixelDataOffset = 0; // dummy initialization
860 860
861 { 861 {
862 std::string s; 862 std::string s;
863 if (index_.LookupMetadata(s, instancePublicId, ResourceType_Instance, 863 if (index_.LookupMetadata(s, instancePublicId, ResourceType_Instance,
864 MetadataType_Instance_PixelDataOffset)) 864 MetadataType_Instance_PixelDataOffset))
900 * can be used to retrieve the truncated DICOM file. Note that 900 * can be used to retrieve the truncated DICOM file. Note that
901 * this case cannot be used if "StorageCompression" option is 901 * this case cannot be used if "StorageCompression" option is
902 * "true". 902 * "true".
903 **/ 903 **/
904 904
905 StorageAccessor accessor(area_, GetMetricsRegistry()); 905 std::unique_ptr<IMemoryBuffer> dicom;
906 std::unique_ptr<IMemoryBuffer> dicom( 906 {
907 area_.ReadRange(attachment.GetUuid(), FileContentType_Dicom, 0, pixelDataOffset)); 907 MetricsRegistry::Timer timer(GetMetricsRegistry(), "orthanc_storage_read_range_duration_ms");
908 dicom.reset(area_.ReadRange(attachment.GetUuid(), FileContentType_Dicom, 0, pixelDataOffset));
909 }
908 910
909 if (dicom.get() == NULL) 911 if (dicom.get() == NULL)
910 { 912 {
911 throw OrthancException(ErrorCode_InternalError); 913 throw OrthancException(ErrorCode_InternalError);
912 } 914 }
971 { 973 {
972 index_.SetMetadata(instancePublicId, MetadataType_Instance_PixelDataOffset, 974 index_.SetMetadata(instancePublicId, MetadataType_Instance_PixelDataOffset,
973 boost::lexical_cast<std::string>(pixelDataOffset)); 975 boost::lexical_cast<std::string>(pixelDataOffset));
974 976
975 if (!area_.HasReadRange() || 977 if (!area_.HasReadRange() ||
976 compressionEnabled_ != CompressionType_None) 978 compressionEnabled_)
977 { 979 {
978 AddAttachment(instancePublicId, FileContentType_DicomUntilPixelData, 980 AddAttachment(instancePublicId, FileContentType_DicomUntilPixelData,
979 dicom.empty() ? NULL: dicom.c_str(), pixelDataOffset); 981 dicom.empty() ? NULL: dicom.c_str(), pixelDataOffset);
980 } 982 }
981 } 983 }