# HG changeset patch # User Alain Mazy # Date 1774867678 -7200 # Node ID 4f05311b113b0542c8d902a764c930e8d347d09c # Parent 7c587343e3088601bf76be958362ac0b54370934 unserialize store job diff -r 7c587343e308 -r 4f05311b113b NEWS --- a/NEWS Mon Mar 30 11:36:16 2026 +0200 +++ b/NEWS Mon Mar 30 12:47:58 2026 +0200 @@ -15,8 +15,6 @@ * When performing a C-Store or a peer transfer, the instances are now grouped per series and ordered by their InstanceNumber instead of using a random order in previous Orthanc versions. -TODO before release: - reconfigure the instancesLoader when unserializing a C-Store or peer job - - serialize the ParentResources in C-Store and peer job * New experimental configuration "PatientLevelEnabled". TODO before release: re-enable test_content_disposition diff -r 7c587343e308 -r 4f05311b113b OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.cpp --- a/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.cpp Mon Mar 30 11:36:16 2026 +0200 +++ b/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.cpp Mon Mar 30 12:47:58 2026 +0200 @@ -274,4 +274,15 @@ hasTrailingStep_ = false; } } + + void SetOfInstancesJob::GetInstancesIds(std::vector& target) const + { + target.clear(); + target.reserve(GetCommandsCount()); + + for (size_t i = 0; i < GetCommandsCount(); ++i) + { + target.push_back(dynamic_cast(GetCommand(i)).GetInstance()); + } + } } diff -r 7c587343e308 -r 4f05311b113b OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h --- a/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h Mon Mar 30 11:36:16 2026 +0200 +++ b/OrthancFramework/Sources/JobsEngine/SetOfInstancesJob.h Mon Mar 30 12:47:58 2026 +0200 @@ -51,6 +51,7 @@ // Hiding this method, use AddInstance() instead using SetOfCommandsJob::AddCommand; + void GetInstancesIds(std::vector& target) const; public: SetOfInstancesJob(); diff -r 7c587343e308 -r 4f05311b113b OrthancServer/Sources/ServerJobs/StoreJob.cpp --- a/OrthancServer/Sources/ServerJobs/StoreJob.cpp Mon Mar 30 11:36:16 2026 +0200 +++ b/OrthancServer/Sources/ServerJobs/StoreJob.cpp Mon Mar 30 12:47:58 2026 +0200 @@ -45,6 +45,21 @@ SetOfInstancesJob(serialized), context_(context) { + // we need to rebuild the instancesIds_ and filesInfo_ from the SetOfInstancesJob + GetInstancesIds(instancesIds_); + + for (size_t i = 0; i < instancesIds_.size(); ++i) + { + FileInfo fileInfo; + int64_t revisionNotUsed; + if (!context.GetIndex().LookupAttachment(fileInfo, revisionNotUsed, ResourceType_Instance, instancesIds_[i], FileContentType_Dicom)) + { + throw OrthancException(ErrorCode_UnknownResource, std::string("Error while unserializing a job, unable to find DICOM attachment for instance ") + instancesIds_[i]); + } + + filesInfo_.push_back(fileInfo); + } + } void StoreJob::AddInstances(const std::vector& instancesIds, @@ -87,7 +102,8 @@ { if (reason == JobStopReason_Canceled || reason == JobStopReason_Failure || - reason == JobStopReason_Retry) + reason == JobStopReason_Retry || + reason == JobStopReason_Success) { // clear the loader threads if (instancesLoader_.get() != NULL) diff -r 7c587343e308 -r 4f05311b113b OrthancServer/Sources/ServerJobs/StoreJob.h --- a/OrthancServer/Sources/ServerJobs/StoreJob.h Mon Mar 30 11:36:16 2026 +0200 +++ b/OrthancServer/Sources/ServerJobs/StoreJob.h Mon Mar 30 12:47:58 2026 +0200 @@ -39,7 +39,6 @@ protected: ServerContext& context_; std::unique_ptr instancesLoader_; - // TODO: re-create when unserializing (in AddParentResources ?) std::vector instancesIds_; std::vector filesInfo_; diff -r 7c587343e308 -r 4f05311b113b TODO --- a/TODO Mon Mar 30 11:36:16 2026 +0200 +++ b/TODO Mon Mar 30 12:47:58 2026 +0200 @@ -71,8 +71,6 @@ "admin": { "Password": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8", "Hashing": "sha1"} } -* Reuse the ThreadedInstanceLoader from the ArchiveJob in C-Store, peer/store ... to optimize loading - time when working with an object storage. ============================