changeset 6837:5ac81cbba1c2 streaming

removed methods from ServerContext: IsCheckMD5() and GetStorageAreaReader()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 21 May 2026 12:32:01 +0200
parents 9ae0a5b7772f
children 7607ed3d07ff
files OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Sources/ServerContext.cpp OrthancServer/Sources/ServerContext.h OrthancServer/Sources/ServerJobs/ThreadedInstancesLoader.cpp
diffstat 4 files changed, 27 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Thu May 21 12:09:16 2026 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Thu May 21 12:32:01 2026 +0200
@@ -2389,9 +2389,7 @@
 
       if (hasRangeHeader)
       {
-        std::unique_ptr<StorageAreaDataSource::Range> fragment(
-          StorageAreaDataSource::ReadRange(
-            context.GetStorageAreaReader(), info, range, uncompress, context.IsCheckMD5()));
+        std::unique_ptr<StorageAreaDataSource::Range> fragment(context.ReadAttachment(info, range, uncompress));
 
         uint64_t fullSize = (uncompress ? info.GetUncompressedSize() : info.GetCompressedSize());
         call.GetOutput().GetLowLevelOutput().SetContentType(MimeType_Binary);
@@ -2406,10 +2404,7 @@
       else
       {
         // Access to the raw attachment (which is compressed)
-        std::unique_ptr<StorageAreaDataSource::Range> content(
-          StorageAreaDataSource::ReadAttachment(
-            context.GetStorageAreaReader(), info, false /* don't uncompress */, context.IsCheckMD5()));
-
+        std::unique_ptr<StorageAreaDataSource::Range> content(context.ReadAttachment(info, false /* don't uncompress */));
         call.GetOutput().AnswerBuffer(content->GetData(), content->GetSize(), MimeType_Binary);
       }
     }
@@ -2591,9 +2586,7 @@
     std::string compressedMD5;
 
     {
-      std::unique_ptr<StorageAreaDataSource::Range> compressed(
-        StorageAreaDataSource::ReadAttachment(
-          context.GetStorageAreaReader(), info, false /* don't uncompress */, false /* check MD5 */));
+      std::unique_ptr<StorageAreaDataSource::Range> compressed(context.ReadAttachment(info, false /* don't uncompress */));
       Toolbox::ComputeMD5(compressedMD5, compressed->GetData(), compressed->GetSize());
     }
     
@@ -2610,9 +2603,7 @@
         std::string uncompressedMD5;
 
         {
-          std::unique_ptr<StorageAreaDataSource::Range> uncompressed(
-            StorageAreaDataSource::ReadAttachment(
-              context.GetStorageAreaReader(), info, true /* uncompress */, false /* check MD5 */));
+          std::unique_ptr<StorageAreaDataSource::Range> uncompressed(context.ReadAttachment(info, true /* uncompress */));
           Toolbox::ComputeMD5(uncompressedMD5, uncompressed->GetData(), uncompressed->GetSize());
         }
 
--- a/OrthancServer/Sources/ServerContext.cpp	Thu May 21 12:09:16 2026 +0200
+++ b/OrthancServer/Sources/ServerContext.cpp	Thu May 21 12:32:01 2026 +0200
@@ -1472,6 +1472,21 @@
   }
 
 
+  StorageAreaDataSource::Range* ServerContext::ReadAttachment(const FileInfo& attachment,
+                                                              bool uncompress)
+  {
+    return StorageAreaDataSource::ReadAttachment(*storageAreaReader_, attachment, uncompress, checkMD5_);
+  }
+
+
+  StorageAreaDataSource::Range* ServerContext::ReadAttachment(const FileInfo& attachment,
+                                                              const StorageRange& range,
+                                                              bool uncompress)
+  {
+    return StorageAreaDataSource::ReadRange(*storageAreaReader_, attachment, range, uncompress, checkMD5_);
+  }
+
+
   StorageAreaDataSource::Range* ServerContext::ReadRawDicom(const std::string& instancePublicId)
   {
     return StorageAreaDataSource::ReadAttachment(*storageAreaReader_, LookupDicomForInstance(instancePublicId),
--- a/OrthancServer/Sources/ServerContext.h	Thu May 21 12:09:16 2026 +0200
+++ b/OrthancServer/Sources/ServerContext.h	Thu May 21 12:32:01 2026 +0200
@@ -384,6 +384,13 @@
 
     FileInfo LookupDicomForInstance(const std::string& instancePublicId);
 
+    StorageAreaDataSource::Range* ReadAttachment(const FileInfo& attachment,
+                                                 bool uncompress);
+
+    StorageAreaDataSource::Range* ReadAttachment(const FileInfo& attachment,
+                                                 const StorageRange& range,
+                                                 bool uncompress);
+
     StorageAreaDataSource::Range* ReadRawDicom(const std::string& instancePublicId);
 
     DicomDataSource::Dicom* ReadParsedDicom(const std::string& instancePublicId);
@@ -582,16 +589,6 @@
 
     const boost::shared_ptr<ServerTranscoder>& GetTranscoder() const;  // TODO-Streaming : REMOVE
 
-    bool IsCheckMD5() const
-    {
-      return checkMD5_;
-    }
-
-    DataSourceReader& GetStorageAreaReader() const  // TODO-Streaming : REMOVE?
-    {
-      return *storageAreaReader_;
-    }
-
     Future* SubmitTranscodingRequest(TranscodingCallable* callable);
   };
 }
--- a/OrthancServer/Sources/ServerJobs/ThreadedInstancesLoader.cpp	Thu May 21 12:09:16 2026 +0200
+++ b/OrthancServer/Sources/ServerJobs/ThreadedInstancesLoader.cpp	Thu May 21 12:32:01 2026 +0200
@@ -181,9 +181,7 @@
 
         {
           std::unique_ptr<StorageAreaDataSource::Range> tmp(
-            StorageAreaDataSource::ReadAttachment(
-              that->context_.GetStorageAreaReader(), instanceToPreload->GetFileInfo(),
-              true /* uncompress */, that->context_.IsCheckMD5()));
+            that->context_.ReadAttachment(instanceToPreload->GetFileInfo(), true /* uncompress */));
           tmp->Copy(*dicomContent);
         }