Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerContext.cpp @ 4640:66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 26 Apr 2021 15:22:44 +0200 |
parents | 88e892e25a51 |
children | 3294385a245a |
comparison
equal
deleted
inserted
replaced
4639:c638dd444de0 | 4640:66109d24d26e |
---|---|
797 content.size(), attachmentType, compression, storeMD5_); | 797 content.size(), attachmentType, compression, storeMD5_); |
798 | 798 |
799 try | 799 try |
800 { | 800 { |
801 int64_t newRevision; // ignored | 801 int64_t newRevision; // ignored |
802 StoreStatus status = index_.AddAttachment(newRevision, modified, resourceId, true, revision); | 802 StoreStatus status = index_.AddAttachment(newRevision, modified, resourceId, |
803 true, revision, modified.GetUncompressedMD5()); | |
803 if (status != StoreStatus_Success) | 804 if (status != StoreStatus_Success) |
804 { | 805 { |
805 accessor.Remove(modified); | 806 accessor.Remove(modified); |
806 throw OrthancException(ErrorCode_Database); | 807 throw OrthancException(ErrorCode_Database); |
807 } | 808 } |
984 compressionEnabled_) | 985 compressionEnabled_) |
985 { | 986 { |
986 int64_t newRevision; | 987 int64_t newRevision; |
987 AddAttachment(newRevision, instancePublicId, FileContentType_DicomUntilPixelData, | 988 AddAttachment(newRevision, instancePublicId, FileContentType_DicomUntilPixelData, |
988 dicom.empty() ? NULL: dicom.c_str(), pixelDataOffset, | 989 dicom.empty() ? NULL: dicom.c_str(), pixelDataOffset, |
989 false /* no old revision */, -1 /* dummy revision */); | 990 false /* no old revision */, -1 /* dummy revision */, "" /* dummy MD5 */); |
990 } | 991 } |
991 } | 992 } |
992 } | 993 } |
993 } | 994 } |
994 } | 995 } |
1160 const std::string& resourceId, | 1161 const std::string& resourceId, |
1161 FileContentType attachmentType, | 1162 FileContentType attachmentType, |
1162 const void* data, | 1163 const void* data, |
1163 size_t size, | 1164 size_t size, |
1164 bool hasOldRevision, | 1165 bool hasOldRevision, |
1165 int64_t oldRevision) | 1166 int64_t oldRevision, |
1167 const std::string& oldMD5) | |
1166 { | 1168 { |
1167 LOG(INFO) << "Adding attachment " << EnumerationToString(attachmentType) << " to resource " << resourceId; | 1169 LOG(INFO) << "Adding attachment " << EnumerationToString(attachmentType) << " to resource " << resourceId; |
1168 | 1170 |
1169 // TODO Should we use "gzip" instead? | 1171 // TODO Should we use "gzip" instead? |
1170 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None); | 1172 CompressionType compression = (compressionEnabled_ ? CompressionType_ZlibWithSize : CompressionType_None); |
1171 | 1173 |
1172 StorageAccessor accessor(area_, GetMetricsRegistry()); | 1174 StorageAccessor accessor(area_, GetMetricsRegistry()); |
1173 FileInfo attachment = accessor.Write(data, size, attachmentType, compression, storeMD5_); | 1175 FileInfo attachment = accessor.Write(data, size, attachmentType, compression, storeMD5_); |
1174 | 1176 |
1175 StoreStatus status = index_.AddAttachment(newRevision, attachment, resourceId, hasOldRevision, oldRevision); | 1177 StoreStatus status = index_.AddAttachment( |
1178 newRevision, attachment, resourceId, hasOldRevision, oldRevision, oldMD5); | |
1176 if (status != StoreStatus_Success) | 1179 if (status != StoreStatus_Success) |
1177 { | 1180 { |
1178 accessor.Remove(attachment); | 1181 accessor.Remove(attachment); |
1179 return false; | 1182 return false; |
1180 } | 1183 } |