# HG changeset patch # User Sebastien Jodogne # Date 1612867033 -3600 # Node ID 7b99e8bb82468a5f7d12fe3c1fc1bbe31555d626 # Parent 10357b2f7150bf03bc02db7ecbed1b21e03eb6f1 IStorageArea::HasReadRange() diff -r 10357b2f7150 -r 7b99e8bb8246 OrthancFramework/Sources/FileStorage/FilesystemStorage.h --- 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; diff -r 10357b2f7150 -r 7b99e8bb8246 OrthancFramework/Sources/FileStorage/IStorageArea.h --- 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; }; diff -r 10357b2f7150 -r 7b99e8bb8246 OrthancFramework/Sources/FileStorage/MemoryStorageArea.cpp --- 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) { diff -r 10357b2f7150 -r 7b99e8bb8246 OrthancFramework/Sources/FileStorage/MemoryStorageArea.h --- 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; }; diff -r 10357b2f7150 -r 7b99e8bb8246 OrthancServer/Plugins/Engine/OrthancPlugins.cpp --- 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); + } }; diff -r 10357b2f7150 -r 7b99e8bb8246 OrthancServer/Sources/OrthancInitialization.cpp --- 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 { diff -r 10357b2f7150 -r 7b99e8bb8246 OrthancServer/Sources/ServerContext.h --- 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, diff -r 10357b2f7150 -r 7b99e8bb8246 OrthancServer/Sources/ServerToolbox.cpp --- 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()); } }