Mercurial > hg > orthanc
diff OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp @ 5136:e71b22a43c0b
Threaded modifications continued: call ReconstructInstance at the end of the modification to update the DB model
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 17 Jan 2023 17:54:38 +0100 |
parents | 6aa41d86b948 |
children | 15109c3f0f7d |
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp Wed Jan 11 11:14:00 2023 +0100 +++ b/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp Tue Jan 17 17:54:38 2023 +0100 @@ -161,8 +161,32 @@ return false; } }; + + // Reset is called when resubmitting a failed job + void ResourceModificationJob::Reset() + { + boost::recursive_mutex::scoped_lock lock(mutex_); + + // TODO: cleanup the instances that have been generated during the previous run + modifiedInstances_.clear(); + + ThreadedSetOfInstancesJob::Reset(); + } + + void ResourceModificationJob::PostProcessInstances() + { + boost::recursive_mutex::scoped_lock lock(mutex_); + + // reconstruct the parents MainDicomTags in case one of them has changed + if (modifiedInstances_.size() > 0) + { + ServerContext::DicomCacheLocker locker(GetContext(), *(modifiedInstances_.begin())); + ParsedDicomFile& modifiedDicom = locker.GetDicom(); + + GetContext().GetIndex().ReconstructInstance(modifiedDicom); + } - + } bool ResourceModificationJob::HandleInstance(const std::string& instance) { @@ -296,6 +320,7 @@ boost::recursive_mutex::scoped_lock lock(outputMutex_); output_->Update(modifiedHasher); + modifiedInstances_.insert(modifiedInstance); } return true; @@ -303,7 +328,7 @@ ResourceModificationJob::ResourceModificationJob(ServerContext& context, unsigned int workersCount) : - ThreadedSetOfInstancesJob(context, false /* no post processing step */, true /* by default, keep source */, workersCount), + ThreadedSetOfInstancesJob(context, true /* post processing step */, true /* by default, keep source */, workersCount), isAnonymization_(false), transcode_(false), transferSyntax_(DicomTransferSyntax_LittleEndianExplicit) // dummy initialization