Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5427:111e21b4f8bc
fix transcoded instance caching
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 17 Nov 2023 08:22:17 +0100 |
parents | c65e036d649b |
children | 59e3b6f8c5be |
comparison
equal
deleted
inserted
replaced
5426:c65e036d649b | 5427:111e21b4f8bc |
---|---|
423 } | 423 } |
424 | 424 |
425 if (call.HasArgument(TRANSCODE)) | 425 if (call.HasArgument(TRANSCODE)) |
426 { | 426 { |
427 std::string source; | 427 std::string source; |
428 std::string attachmentId; | |
428 std::string transcoded; | 429 std::string transcoded; |
429 context.ReadDicom(source, publicId); | 430 context.ReadDicom(source, attachmentId, publicId); |
430 | 431 |
431 if (context.TranscodeWithCache(transcoded, source, publicId, GetTransferSyntax(call.GetArgument(TRANSCODE, "")))) | 432 if (context.TranscodeWithCache(transcoded, source, publicId, attachmentId, GetTransferSyntax(call.GetArgument(TRANSCODE, "")))) |
432 { | 433 { |
433 call.GetOutput().AnswerBuffer(transcoded, MimeType_Dicom); | 434 call.GetOutput().AnswerBuffer(transcoded, MimeType_Dicom); |
434 } | 435 } |
435 } | 436 } |
436 else | 437 else |
2326 } | 2327 } |
2327 else | 2328 else |
2328 { | 2329 { |
2329 // Return the raw data (possibly compressed), as stored on the filesystem | 2330 // Return the raw data (possibly compressed), as stored on the filesystem |
2330 std::string content; | 2331 std::string content; |
2332 std::string attachmentId; | |
2331 int64_t revision; | 2333 int64_t revision; |
2332 context.ReadAttachment(content, revision, publicId, type, false, true /* skipCache when you absolutely need the compressed data */); | 2334 context.ReadAttachment(content, revision, attachmentId, publicId, type, false, true /* skipCache when you absolutely need the compressed data */); |
2333 | 2335 |
2334 int64_t userRevision; | 2336 int64_t userRevision; |
2335 std::string userMD5; | 2337 std::string userMD5; |
2336 if (GetRevisionHeader(userRevision, userMD5, call, "If-None-Match") && | 2338 if (GetRevisionHeader(userRevision, userMD5, call, "If-None-Match") && |
2337 revision == userRevision && | 2339 revision == userRevision && |
2509 | 2511 |
2510 bool ok = false; | 2512 bool ok = false; |
2511 | 2513 |
2512 // First check whether the compressed data is correctly stored in the disk | 2514 // First check whether the compressed data is correctly stored in the disk |
2513 std::string data; | 2515 std::string data; |
2514 context.ReadAttachment(data, revision, publicId, StringToContentType(name), false, true /* skipCache when you absolutely need the compressed data */); | 2516 std::string attachmentId; |
2517 | |
2518 context.ReadAttachment(data, revision, attachmentId, publicId, StringToContentType(name), false, true /* skipCache when you absolutely need the compressed data */); | |
2515 | 2519 |
2516 std::string actualMD5; | 2520 std::string actualMD5; |
2517 Toolbox::ComputeMD5(actualMD5, data); | 2521 Toolbox::ComputeMD5(actualMD5, data); |
2518 | 2522 |
2519 if (actualMD5 == info.GetCompressedMD5()) | 2523 if (actualMD5 == info.GetCompressedMD5()) |
2524 { | 2528 { |
2525 ok = true; | 2529 ok = true; |
2526 } | 2530 } |
2527 else | 2531 else |
2528 { | 2532 { |
2529 context.ReadAttachment(data, revision, publicId, StringToContentType(name), true, true /* skipCache when you absolutely need the compressed data */); | 2533 context.ReadAttachment(data, revision, attachmentId, publicId, StringToContentType(name), true, true /* skipCache when you absolutely need the compressed data */); |
2530 Toolbox::ComputeMD5(actualMD5, data); | 2534 Toolbox::ComputeMD5(actualMD5, data); |
2531 ok = (actualMD5 == info.GetUncompressedMD5()); | 2535 ok = (actualMD5 == info.GetUncompressedMD5()); |
2532 } | 2536 } |
2533 } | 2537 } |
2534 | 2538 |