comparison OrthancServer/Sources/ServerIndex.cpp @ 4579:5ee9a4f8a0f0 db-changes

fix build on lsb
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Mar 2021 14:30:05 +0100
parents 710748828b6a
children 49f6b9a2b9f5
comparison
equal deleted inserted replaced
4578:710748828b6a 4579:5ee9a4f8a0f0
2926 Apply(operations); 2926 Apply(operations);
2927 } 2927 }
2928 2928
2929 2929
2930 void ServerIndex::LogChange(ChangeType changeType, 2930 void ServerIndex::LogChange(ChangeType changeType,
2931 const std::string& publicId) 2931 const std::string& publicId,
2932 ResourceType level)
2932 { 2933 {
2933 class Operations : public IReadWriteOperations 2934 class Operations : public IReadWriteOperations
2934 { 2935 {
2935 private: 2936 private:
2936 ChangeType changeType_; 2937 ChangeType changeType_;
2937 const std::string& publicId_; 2938 const std::string& publicId_;
2939 ResourceType level_;
2938 2940
2939 public: 2941 public:
2940 Operations(ChangeType changeType, 2942 Operations(ChangeType changeType,
2941 const std::string& publicId) : 2943 const std::string& publicId,
2944 ResourceType level) :
2942 changeType_(changeType), 2945 changeType_(changeType),
2943 publicId_(publicId) 2946 publicId_(publicId),
2947 level_(level)
2944 { 2948 {
2945 } 2949 }
2946 2950
2947 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE 2951 virtual void Apply(ReadWriteTransaction& transaction) ORTHANC_OVERRIDE
2948 { 2952 {
2949 int64_t id; 2953 int64_t id;
2950 ResourceType type; 2954 ResourceType type;
2951 if (!transaction.LookupResource(id, type, publicId_)) 2955 if (transaction.LookupResource(id, type, publicId_))
2952 { 2956 {
2953 throw OrthancException(ErrorCode_UnknownResource); 2957 // Make sure that the resource is still existing. Ignore if
2954 } 2958 // the resource has been deleted, because this function
2955 else 2959 // might e.g. be called from
2956 { 2960 // "ServerIndex::UnstableResourcesMonitorThread()" (for
2957 transaction.LogChange(id, changeType_, type, publicId_); 2961 // which a deleted resource not an error case)
2958 } 2962 if (type == level_)
2959 } 2963 {
2960 }; 2964 transaction.LogChange(id, changeType_, type, publicId_);
2961 2965 }
2962 Operations operations(changeType, publicId); 2966 else
2967 {
2968 // Consistency check
2969 throw OrthancException(ErrorCode_UnknownResource);
2970 }
2971 }
2972 }
2973 };
2974
2975 Operations operations(changeType, publicId, level);
2963 Apply(operations); 2976 Apply(operations);
2964 } 2977 }
2965 2978
2966 2979
2967 void ServerIndex::ReconstructInstance(const ParsedDicomFile& dicom) 2980 void ServerIndex::ReconstructInstance(const ParsedDicomFile& dicom)
3509 } 3522 }
3510 } 3523 }
3511 }; 3524 };
3512 3525
3513 3526
3514 std::unique_ptr<Operations> operations; 3527 uint64_t maximumStorageSize;
3528 unsigned int maximumPatients;
3515 3529
3516 { 3530 {
3517 boost::mutex::scoped_lock lock(monitoringMutex_); 3531 boost::mutex::scoped_lock lock(monitoringMutex_);
3518 operations.reset(new Operations(instanceMetadata, *this, dicomSummary, attachments, metadata, origin, 3532 maximumStorageSize = maximumStorageSize_;
3519 overwrite, hasTransferSyntax, transferSyntax, hasPixelDataOffset, 3533 maximumPatients = maximumPatients_;
3520 pixelDataOffset, maximumStorageSize_, maximumPatients_)); 3534 }
3521 } 3535
3522 3536 Operations operations(instanceMetadata, *this, dicomSummary, attachments, metadata, origin,
3523 Apply(*operations); 3537 overwrite, hasTransferSyntax, transferSyntax, hasPixelDataOffset,
3524 return operations->GetStoreStatus(); 3538 pixelDataOffset, maximumStorageSize, maximumPatients);
3539 Apply(operations);
3540 return operations.GetStoreStatus();
3525 } 3541 }
3526 3542
3527 3543
3528 StoreStatus ServerIndex::AddAttachment(const FileInfo& attachment, 3544 StoreStatus ServerIndex::AddAttachment(const FileInfo& attachment,
3529 const std::string& publicId) 3545 const std::string& publicId)
3603 } 3619 }
3604 } 3620 }
3605 }; 3621 };
3606 3622
3607 3623
3608 std::unique_ptr<Operations> operations; 3624 uint64_t maximumStorageSize;
3625 unsigned int maximumPatients;
3609 3626
3610 { 3627 {
3611 boost::mutex::scoped_lock lock(monitoringMutex_); 3628 boost::mutex::scoped_lock lock(monitoringMutex_);
3612 operations.reset(new Operations(attachment, publicId, maximumStorageSize_, maximumPatients_)); 3629 maximumStorageSize = maximumStorageSize_;
3613 } 3630 maximumPatients = maximumPatients_;
3614 3631 }
3615 Apply(*operations); 3632
3616 return operations->GetStatus(); 3633 Operations operations(attachment, publicId, maximumStorageSize, maximumPatients);
3634 Apply(operations);
3635 return operations.GetStatus();
3617 } 3636 }
3618 } 3637 }