# HG changeset patch # User Sebastien Jodogne # Date 1615296605 -3600 # Node ID 5ee9a4f8a0f0254985ab29f2d64277eb59b0ac7a # Parent 710748828b6a4dffbdbf630142c9ae1e462109e2 fix build on lsb diff -r 710748828b6a -r 5ee9a4f8a0f0 OrthancServer/Sources/Database/IDatabaseListener.h --- a/OrthancServer/Sources/Database/IDatabaseListener.h Tue Mar 09 11:55:08 2021 +0100 +++ b/OrthancServer/Sources/Database/IDatabaseListener.h Tue Mar 09 14:30:05 2021 +0100 @@ -33,7 +33,7 @@ #pragma once -#include "../../OrthancFramework/Sources/FileStorage/FileInfo.h" +#include "../../../OrthancFramework/Sources/FileStorage/FileInfo.h" #include "../ServerEnumerations.h" #include diff -r 710748828b6a -r 5ee9a4f8a0f0 OrthancServer/Sources/ServerIndex.cpp --- a/OrthancServer/Sources/ServerIndex.cpp Tue Mar 09 11:55:08 2021 +0100 +++ b/OrthancServer/Sources/ServerIndex.cpp Tue Mar 09 14:30:05 2021 +0100 @@ -2928,19 +2928,23 @@ void ServerIndex::LogChange(ChangeType changeType, - const std::string& publicId) + const std::string& publicId, + ResourceType level) { class Operations : public IReadWriteOperations { private: ChangeType changeType_; const std::string& publicId_; + ResourceType level_; public: Operations(ChangeType changeType, - const std::string& publicId) : + const std::string& publicId, + ResourceType level) : changeType_(changeType), - publicId_(publicId) + publicId_(publicId), + level_(level) { } @@ -2948,18 +2952,27 @@ { int64_t id; ResourceType type; - if (!transaction.LookupResource(id, type, publicId_)) + if (transaction.LookupResource(id, type, publicId_)) { - throw OrthancException(ErrorCode_UnknownResource); - } - else - { - transaction.LogChange(id, changeType_, type, publicId_); + // Make sure that the resource is still existing. Ignore if + // the resource has been deleted, because this function + // might e.g. be called from + // "ServerIndex::UnstableResourcesMonitorThread()" (for + // which a deleted resource not an error case) + if (type == level_) + { + transaction.LogChange(id, changeType_, type, publicId_); + } + else + { + // Consistency check + throw OrthancException(ErrorCode_UnknownResource); + } } } }; - Operations operations(changeType, publicId); + Operations operations(changeType, publicId, level); Apply(operations); } @@ -3511,17 +3524,20 @@ }; - std::unique_ptr operations; + uint64_t maximumStorageSize; + unsigned int maximumPatients; { boost::mutex::scoped_lock lock(monitoringMutex_); - operations.reset(new Operations(instanceMetadata, *this, dicomSummary, attachments, metadata, origin, - overwrite, hasTransferSyntax, transferSyntax, hasPixelDataOffset, - pixelDataOffset, maximumStorageSize_, maximumPatients_)); + maximumStorageSize = maximumStorageSize_; + maximumPatients = maximumPatients_; } - Apply(*operations); - return operations->GetStoreStatus(); + Operations operations(instanceMetadata, *this, dicomSummary, attachments, metadata, origin, + overwrite, hasTransferSyntax, transferSyntax, hasPixelDataOffset, + pixelDataOffset, maximumStorageSize, maximumPatients); + Apply(operations); + return operations.GetStoreStatus(); } @@ -3605,14 +3621,17 @@ }; - std::unique_ptr operations; + uint64_t maximumStorageSize; + unsigned int maximumPatients; { boost::mutex::scoped_lock lock(monitoringMutex_); - operations.reset(new Operations(attachment, publicId, maximumStorageSize_, maximumPatients_)); + maximumStorageSize = maximumStorageSize_; + maximumPatients = maximumPatients_; } - Apply(*operations); - return operations->GetStatus(); + Operations operations(attachment, publicId, maximumStorageSize, maximumPatients); + Apply(operations); + return operations.GetStatus(); } } diff -r 710748828b6a -r 5ee9a4f8a0f0 OrthancServer/Sources/ServerIndex.h --- a/OrthancServer/Sources/ServerIndex.h Tue Mar 09 11:55:08 2021 +0100 +++ b/OrthancServer/Sources/ServerIndex.h Tue Mar 09 14:30:05 2021 +0100 @@ -586,7 +586,8 @@ FileContentType type); void LogChange(ChangeType changeType, - const std::string& publicId); + const std::string& publicId, + ResourceType level); void ReconstructInstance(const ParsedDicomFile& dicom);