# HG changeset patch # User Alain Mazy # Date 1727364223 -7200 # Node ID 272b0d0eef387b2933f524c12c16ddfbf1aabfeb # Parent 8a8756b2dd0b574d9bb90423fdce4f4ae18d3b88 ReadOnly mode continued diff -r 8a8756b2dd0b -r 272b0d0eef38 OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Mon Sep 23 16:03:02 2024 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Thu Sep 26 17:23:43 2024 +0200 @@ -1042,7 +1042,7 @@ } }; - if (GetDatabaseCapabilities().HasUpdateAndGetStatistics()) + if (GetDatabaseCapabilities().HasUpdateAndGetStatistics() && !IsReadOnly()) { Operations operations; Apply(operations); diff -r 8a8756b2dd0b -r 272b0d0eef38 OrthancServer/Sources/Database/StatelessDatabaseOperations.h --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Mon Sep 23 16:03:02 2024 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Thu Sep 26 17:23:43 2024 +0200 @@ -608,6 +608,11 @@ uint64_t maximumStorageSize, unsigned int maximumPatientCount); + bool IsReadOnly() + { + return readOnly_; + } + public: explicit StatelessDatabaseOperations(IDatabaseWrapper& database, bool readOnly); diff -r 8a8756b2dd0b -r 272b0d0eef38 OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp Mon Sep 23 16:03:02 2024 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp Thu Sep 26 17:23:43 2024 +0200 @@ -270,7 +270,16 @@ RegisterAnonymizeModify(); RegisterArchive(); - Register("/instances", UploadDicomFile); + if (!context_.IsReadOnly()) + { + Register("/instances", UploadDicomFile); + } + else + { + LOG(WARNING) << "READ-ONLY SYSTEM: deactivating POST /instances route"; + } + + // Auto-generated directories Register("/tools", RestApi::AutoListChildren); diff -r 8a8756b2dd0b -r 272b0d0eef38 OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Mon Sep 23 16:03:02 2024 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Thu Sep 26 17:23:43 2024 +0200 @@ -4380,7 +4380,7 @@ } else { - LOG(WARNING) << "READ-ONLY SYSTEM: DELETE routes are not available"; + LOG(WARNING) << "READ-ONLY SYSTEM: deactivating DELETE routes"; } Register("/instances/{id}", GetSingleResource); @@ -4437,7 +4437,7 @@ } else { - LOG(WARNING) << "READ-ONLY SYSTEM: PUT /patients/{id}/protected route is not available"; + LOG(WARNING) << "READ-ONLY SYSTEM: deactivating PUT /patients/{id}/protected route"; } diff -r 8a8756b2dd0b -r 272b0d0eef38 OrthancServer/Sources/ServerContext.cpp --- a/OrthancServer/Sources/ServerContext.cpp Mon Sep 23 16:03:02 2024 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Thu Sep 26 17:23:43 2024 +0200 @@ -406,7 +406,14 @@ new SharedArchive(lock.GetConfiguration().GetUnsignedIntegerParameter("MediaArchiveSize", 1))); defaultLocalAet_ = lock.GetConfiguration().GetOrthancAET(); jobsEngine_.SetWorkersCount(lock.GetConfiguration().GetUnsignedIntegerParameter("ConcurrentJobs", 2)); + saveJobs_ = lock.GetConfiguration().GetBooleanParameter("SaveJobs", true); + if (readOnly_ && saveJobs_) + { + LOG(WARNING) << "READ-ONLY SYSTEM: SaveJobs = true is incompatible with a ReadOnly system, ignoring this configuration"; + saveJobs_ = false; + } + metricsRegistry_->SetEnabled(lock.GetConfiguration().GetBooleanParameter("MetricsEnabled", true)); // New configuration options in Orthanc 1.5.1 diff -r 8a8756b2dd0b -r 272b0d0eef38 OrthancServer/Sources/ServerIndex.cpp --- a/OrthancServer/Sources/ServerIndex.cpp Mon Sep 23 16:03:02 2024 +0200 +++ b/OrthancServer/Sources/ServerIndex.cpp Thu Sep 26 17:23:43 2024 +0200 @@ -352,7 +352,8 @@ done_(false), maximumStorageMode_(MaxStorageMode_Recycle), maximumStorageSize_(0), - maximumPatients_(0) + maximumPatients_(0), + readOnly_(readOnly) { SetTransactionContextFactory(new TransactionContextFactory(context)); diff -r 8a8756b2dd0b -r 272b0d0eef38 OrthancServer/Sources/ServerIndex.h --- a/OrthancServer/Sources/ServerIndex.h Mon Sep 23 16:03:02 2024 +0200 +++ b/OrthancServer/Sources/ServerIndex.h Thu Sep 26 17:23:43 2024 +0200 @@ -50,6 +50,7 @@ MaxStorageMode maximumStorageMode_; uint64_t maximumStorageSize_; unsigned int maximumPatients_; + bool readOnly_; static void FlushThread(ServerIndex* that, unsigned int threadSleep); diff -r 8a8756b2dd0b -r 272b0d0eef38 OrthancServer/Sources/main.cpp --- a/OrthancServer/Sources/main.cpp Mon Sep 23 16:03:02 2024 +0200 +++ b/OrthancServer/Sources/main.cpp Thu Sep 26 17:23:43 2024 +0200 @@ -1570,12 +1570,7 @@ if (context.IsReadOnly()) { - LOG(WARNING) << "READ-ONLY SYSTEM: ignoring these configurations: StorageCompression, StoreMD5ForAttachments, OverwriteInstances, MaximumPatientCount, MaximumStorageSize, MaximumStorageMode"; - - if (context.IsSaveJobs()) - { - throw OrthancException(ErrorCode_IncompatibleConfigurations, "\"SaveJobs\" can not be true when \"ReadOnly\" is true"); - } + LOG(WARNING) << "READ-ONLY SYSTEM: ignoring these configurations: StorageCompression, StoreMD5ForAttachments, OverwriteInstances, MaximumPatientCount, MaximumStorageSize, MaximumStorageMode, SaveJobs"; } else {