comparison OrthancFramework/Sources/FileStorage/StorageAccessor.cpp @ 5059:5c997c72603c

Fix the Storage Cache for compressed files (bug introduced in 1.11.0)
author Alain Mazy <am@osimis.io>
date Mon, 08 Aug 2022 09:59:07 +0200
parents 22966345eaba
children d7274e43ea7c dd085f7e7e71
comparison
equal deleted inserted replaced
5058:d4e5ca0c9307 5059:5c997c72603c
267 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 267 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
268 void StorageAccessor::SetupSender(BufferHttpSender& sender, 268 void StorageAccessor::SetupSender(BufferHttpSender& sender,
269 const FileInfo& info, 269 const FileInfo& info,
270 const std::string& mime) 270 const std::string& mime)
271 { 271 {
272 if (cache_ == NULL || !cache_->Fetch(sender.GetBuffer(), info.GetUuid(), info.GetContentType())) 272 Read(sender.GetBuffer(), info);
273 {
274 MetricsTimer timer(*this, METRICS_READ);
275 std::unique_ptr<IMemoryBuffer> buffer(area_.Read(info.GetUuid(), info.GetContentType()));
276 buffer->MoveToString(sender.GetBuffer());
277
278 if (cache_ != NULL)
279 {
280 cache_->Add(info.GetUuid(), info.GetContentType(), sender.GetBuffer());
281 }
282 }
283 273
284 sender.SetContentType(mime); 274 sender.SetContentType(mime);
285 275
286 const char* extension; 276 const char* extension;
287 switch (info.GetContentType()) 277 switch (info.GetContentType())
321 const std::string& mime) 311 const std::string& mime)
322 { 312 {
323 BufferHttpSender sender; 313 BufferHttpSender sender;
324 SetupSender(sender, info, mime); 314 SetupSender(sender, info, mime);
325 315
326 HttpStreamTranscoder transcoder(sender, info.GetCompressionType()); 316 HttpStreamTranscoder transcoder(sender, CompressionType_None); // since 1.11.2, the storage accessor only returns uncompressed buffers
327 output.Answer(transcoder); 317 output.Answer(transcoder);
328 } 318 }
329 #endif 319 #endif
330 320
331 321
345 const std::string& mime) 335 const std::string& mime)
346 { 336 {
347 BufferHttpSender sender; 337 BufferHttpSender sender;
348 SetupSender(sender, info, mime); 338 SetupSender(sender, info, mime);
349 339
350 HttpStreamTranscoder transcoder(sender, info.GetCompressionType()); 340 HttpStreamTranscoder transcoder(sender, CompressionType_None); // since 1.11.2, the storage accessor only returns uncompressed buffers
351 output.AnswerStream(transcoder); 341 output.AnswerStream(transcoder);
352 } 342 }
353 #endif 343 #endif
354 } 344 }