Mercurial > hg > orthanc
diff OrthancFramework/Sources/FileStorage/StorageAccessor.cpp @ 4906:f656fb878b50
reintroduced storage cache for StartRange files
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 21 Feb 2022 10:11:38 +0100 |
parents | 0bb73ef7cf07 |
children | 45d6ce72a84e |
line wrap: on
line diff
--- a/OrthancFramework/Sources/FileStorage/StorageAccessor.cpp Sun Feb 20 16:57:43 2022 +0100 +++ b/OrthancFramework/Sources/FileStorage/StorageAccessor.cpp Mon Feb 21 10:11:38 2022 +0100 @@ -239,16 +239,9 @@ FileContentType contentType, uint64_t end /* exclusive */) { - if (cache_.Fetch(target, fileUuid, contentType)) + if (cache_.FetchStartRange(target, fileUuid, contentType, end)) { - if (target.size() < end) - { - throw OrthancException(ErrorCode_CorruptedFile); - } - else - { - target.resize(end); - } + return; } else { @@ -256,6 +249,8 @@ std::unique_ptr<IMemoryBuffer> buffer(area_.ReadRange(fileUuid, contentType, 0, end)); assert(buffer->GetSize() == end); buffer->MoveToString(target); + + cache_.AddStartRange(fileUuid, contentType, target); } } @@ -270,6 +265,8 @@ MetricsTimer timer(*this, METRICS_READ); std::unique_ptr<IMemoryBuffer> buffer(area_.Read(info.GetUuid(), info.GetContentType())); buffer->MoveToString(sender.GetBuffer()); + + cache_.Add(info.GetUuid(), info.GetContentType(), sender.GetBuffer()); } sender.SetContentType(mime);