comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5048:22966345eaba

skip StorageCache when verifying md5 or when re-compressing attachments
author Alain Mazy <am@osimis.io>
date Wed, 29 Jun 2022 13:15:20 +0200
parents e25689b5f0a3
children 255b02c68908
comparison
equal deleted inserted replaced
5047:207f259c41c5 5048:22966345eaba
2130 else 2130 else
2131 { 2131 {
2132 // Return the raw data (possibly compressed), as stored on the filesystem 2132 // Return the raw data (possibly compressed), as stored on the filesystem
2133 std::string content; 2133 std::string content;
2134 int64_t revision; 2134 int64_t revision;
2135 context.ReadAttachment(content, revision, publicId, type, false); 2135 context.ReadAttachment(content, revision, publicId, type, false, true /* skipCache when you absolutely need the compressed data */);
2136 2136
2137 int64_t userRevision; 2137 int64_t userRevision;
2138 std::string userMD5; 2138 std::string userMD5;
2139 if (GetRevisionHeader(userRevision, userMD5, call, "If-None-Match") && 2139 if (GetRevisionHeader(userRevision, userMD5, call, "If-None-Match") &&
2140 revision == userRevision && 2140 revision == userRevision &&
2312 2312
2313 bool ok = false; 2313 bool ok = false;
2314 2314
2315 // First check whether the compressed data is correctly stored in the disk 2315 // First check whether the compressed data is correctly stored in the disk
2316 std::string data; 2316 std::string data;
2317 context.ReadAttachment(data, revision, publicId, StringToContentType(name), false); 2317 context.ReadAttachment(data, revision, publicId, StringToContentType(name), false, true /* skipCache when you absolutely need the compressed data */);
2318 2318
2319 std::string actualMD5; 2319 std::string actualMD5;
2320 Toolbox::ComputeMD5(actualMD5, data); 2320 Toolbox::ComputeMD5(actualMD5, data);
2321 2321
2322 if (actualMD5 == info.GetCompressedMD5()) 2322 if (actualMD5 == info.GetCompressedMD5())
2327 { 2327 {
2328 ok = true; 2328 ok = true;
2329 } 2329 }
2330 else 2330 else
2331 { 2331 {
2332 context.ReadAttachment(data, revision, publicId, StringToContentType(name), true); 2332 context.ReadAttachment(data, revision, publicId, StringToContentType(name), true, true /* skipCache when you absolutely need the compressed data */);
2333 Toolbox::ComputeMD5(actualMD5, data); 2333 Toolbox::ComputeMD5(actualMD5, data);
2334 ok = (actualMD5 == info.GetUncompressedMD5()); 2334 ok = (actualMD5 == info.GetUncompressedMD5());
2335 } 2335 }
2336 } 2336 }
2337 2337