Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerContext.cpp @ 4900:ea5f1c6ed07e
fix cache of storage area
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 20 Feb 2022 16:29:33 +0100 |
parents | 6eff25f70121 |
children | c1b19f95e166 |
comparison
equal
deleted
inserted
replaced
4898:181e67f9d129 | 4900:ea5f1c6ed07e |
---|---|
951 * can be used to retrieve the truncated DICOM file. Note that | 951 * can be used to retrieve the truncated DICOM file. Note that |
952 * this case cannot be used if "StorageCompression" option is | 952 * this case cannot be used if "StorageCompression" option is |
953 * "true". | 953 * "true". |
954 **/ | 954 **/ |
955 | 955 |
956 std::unique_ptr<IMemoryBuffer> dicom; | 956 std::string dicom; |
957 | |
957 { | 958 { |
958 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); | 959 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); |
959 dicom.reset(accessor.ReadStartRange(attachment.GetUuid(), FileContentType_Dicom, pixelDataOffset, FileContentType_DicomUntilPixelData)); | 960 accessor.ReadStartRange(dicom, attachment.GetUuid(), FileContentType_Dicom, pixelDataOffset); |
960 } | 961 } |
961 | 962 |
962 if (dicom.get() == NULL) | 963 assert(dicom.size() == pixelDataOffset); |
963 { | 964 ParsedDicomFile parsed(dicom); |
964 throw OrthancException(ErrorCode_InternalError); | 965 OrthancConfiguration::DefaultDicomDatasetToJson(result, parsed, ignoreTagLength); |
965 } | 966 InjectEmptyPixelData(result); |
966 else | |
967 { | |
968 assert(dicom->GetSize() == pixelDataOffset); | |
969 ParsedDicomFile parsed(dicom->GetData(), dicom->GetSize()); | |
970 OrthancConfiguration::DefaultDicomDatasetToJson(result, parsed, ignoreTagLength); | |
971 InjectEmptyPixelData(result); | |
972 } | |
973 } | 967 } |
974 else if (ignoreTagLength.empty() && | 968 else if (ignoreTagLength.empty() && |
975 index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_DicomAsJson)) | 969 index_.LookupAttachment(attachment, revision, instancePublicId, FileContentType_DicomAsJson)) |
976 { | 970 { |
977 /** | 971 /** |
1091 { | 1085 { |
1092 uint64_t pixelDataOffset = boost::lexical_cast<uint64_t>(s); | 1086 uint64_t pixelDataOffset = boost::lexical_cast<uint64_t>(s); |
1093 | 1087 |
1094 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); | 1088 StorageAccessor accessor(area_, storageCache_, GetMetricsRegistry()); |
1095 | 1089 |
1096 std::unique_ptr<IMemoryBuffer> buffer( | 1090 accessor.ReadStartRange(dicom, attachment.GetUuid(), attachment.GetContentType(), pixelDataOffset); |
1097 accessor.ReadStartRange(attachment.GetUuid(), attachment.GetContentType(), pixelDataOffset, FileContentType_DicomUntilPixelData)); | 1091 assert(dicom.size() == pixelDataOffset); |
1098 buffer->MoveToString(dicom); | 1092 |
1099 return true; // Success | 1093 return true; // Success |
1100 } | 1094 } |
1101 catch (boost::bad_lexical_cast&) | 1095 catch (boost::bad_lexical_cast&) |
1102 { | 1096 { |
1103 LOG(ERROR) << "Metadata \"PixelDataOffset\" is corrupted for instance: " << instancePublicId; | 1097 LOG(ERROR) << "Metadata \"PixelDataOffset\" is corrupted for instance: " << instancePublicId; |