changeset 4498:7b99e8bb8246

IStorageArea::HasReadRange()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Feb 2021 11:37:13 +0100
parents 10357b2f7150
children 6f99949b2878
files OrthancFramework/Sources/FileStorage/FilesystemStorage.h OrthancFramework/Sources/FileStorage/IStorageArea.h OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp OrthancFramework/Sources/FileStorage/MemoryStorageArea.h OrthancServer/Plugins/Engine/OrthancPlugins.cpp OrthancServer/Sources/OrthancInitialization.cpp OrthancServer/Sources/ServerContext.h OrthancServer/Sources/ServerToolbox.cpp
diffstat 8 files changed, 39 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/FileStorage/FilesystemStorage.h	Mon Feb 08 18:39:22 2021 +0100
+++ b/OrthancFramework/Sources/FileStorage/FilesystemStorage.h	Tue Feb 09 11:37:13 2021 +0100
@@ -86,6 +86,11 @@
                                      uint64_t start /* inclusive */,
                                      uint64_t end /* exclusive */) ORTHANC_OVERRIDE;
 
+    virtual bool HasReadRange() const ORTHANC_OVERRIDE
+    {
+      return true;
+    }
+
     virtual void Remove(const std::string& uuid,
                         FileContentType type) ORTHANC_OVERRIDE;
 
--- a/OrthancFramework/Sources/FileStorage/IStorageArea.h	Mon Feb 08 18:39:22 2021 +0100
+++ b/OrthancFramework/Sources/FileStorage/IStorageArea.h	Tue Feb 09 11:37:13 2021 +0100
@@ -51,6 +51,8 @@
                                      uint64_t start /* inclusive */,
                                      uint64_t end /* exclusive */) = 0;
 
+    virtual bool HasReadRange() const = 0;
+
     virtual void Remove(const std::string& uuid,
                         FileContentType type) = 0;
   };
--- a/OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp	Mon Feb 08 18:39:22 2021 +0100
+++ b/OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp	Tue Feb 09 11:37:13 2021 +0100
@@ -140,6 +140,12 @@
   }
 
 
+  bool MemoryStorageArea::HasReadRange() const
+  {
+    return true;
+  }
+
+
   void MemoryStorageArea::Remove(const std::string& uuid,
                                  FileContentType type)
   {
--- a/OrthancFramework/Sources/FileStorage/MemoryStorageArea.h	Mon Feb 08 18:39:22 2021 +0100
+++ b/OrthancFramework/Sources/FileStorage/MemoryStorageArea.h	Tue Feb 09 11:37:13 2021 +0100
@@ -55,6 +55,8 @@
                                      uint64_t start /* inclusive */,
                                      uint64_t end /* exclusive */) ORTHANC_OVERRIDE;
     
+    virtual bool HasReadRange() const ORTHANC_OVERRIDE;
+
     virtual void Remove(const std::string& uuid,
                         FileContentType type) ORTHANC_OVERRIDE;
   };
--- a/OrthancServer/Plugins/Engine/OrthancPlugins.cpp	Mon Feb 08 18:39:22 2021 +0100
+++ b/OrthancServer/Plugins/Engine/OrthancPlugins.cpp	Tue Feb 09 11:37:13 2021 +0100
@@ -355,6 +355,11 @@
       {
         return RangeFromWhole(uuid, type, start, end);
       }
+
+      virtual bool HasReadRange() const ORTHANC_OVERRIDE
+      {
+        return false;
+      }
     };
 
 
@@ -443,6 +448,11 @@
           }
         }
       }
+      
+      virtual bool HasReadRange() const ORTHANC_OVERRIDE
+      {
+        return (readRange_ != NULL);
+      }
     };
 
 
--- a/OrthancServer/Sources/OrthancInitialization.cpp	Mon Feb 08 18:39:22 2021 +0100
+++ b/OrthancServer/Sources/OrthancInitialization.cpp	Tue Feb 09 11:37:13 2021 +0100
@@ -395,6 +395,11 @@
         }
       }
 
+      virtual bool HasReadRange() const ORTHANC_OVERRIDE
+      {
+        return storage_.HasReadRange();
+      }
+
       virtual void Remove(const std::string& uuid,
                           FileContentType type) ORTHANC_OVERRIDE
       {
--- a/OrthancServer/Sources/ServerContext.h	Mon Feb 08 18:39:22 2021 +0100
+++ b/OrthancServer/Sources/ServerContext.h	Tue Feb 09 11:37:13 2021 +0100
@@ -71,6 +71,8 @@
     public IDicomTranscoder,
     private JobsRegistry::IObserver
   {
+    friend class ServerIndex;  // To access "RemoveFile()"
+    
   public:
     class ILookupVisitor : public boost::noncopyable
     {
@@ -244,6 +246,10 @@
 
     void PublishDicomCacheMetrics();
 
+    // This method must only be called from "ServerIndex"!
+    void RemoveFile(const std::string& fileUuid,
+                    FileContentType type);
+
     // This DicomModification object is intended to be used as a
     // "rules engine" when de-identifying logs for C-Find, C-Get, and
     // C-Move queries (new in Orthanc 1.8.2)
@@ -292,9 +298,6 @@
       return compressionEnabled_;
     }
 
-    void RemoveFile(const std::string& fileUuid,
-                    FileContentType type);
-
     bool AddAttachment(const std::string& resourceId,
                        FileContentType attachmentType,
                        const void* data,
--- a/OrthancServer/Sources/ServerToolbox.cpp	Mon Feb 08 18:39:22 2021 +0100
+++ b/OrthancServer/Sources/ServerToolbox.cpp	Tue Feb 09 11:37:13 2021 +0100
@@ -379,12 +379,9 @@
       {
         ServerContext::DicomCacheLocker locker(context, *it);
 
-        Json::Value dicomAsJson;
-        OrthancConfiguration::DefaultDicomDatasetToJson(dicomAsJson, locker.GetDicom());
-
-        std::string s = dicomAsJson.toStyledString();
-        context.AddAttachment(*it, FileContentType_DicomAsJson, s.c_str(), s.size());
-
+        // Delay the reconstruction of DICOM-as-JSON to its next access through "ServerContext"
+        context.GetIndex().DeleteAttachment(*it, FileContentType_DicomAsJson);
+        
         context.GetIndex().ReconstructInstance(locker.GetDicom());
       }
     }