# HG changeset patch # User Sebastien Jodogne # Date 1354284556 -3600 # Node ID 6d9be2b470b474d6d89b534b24a657d74486d8b1 # Parent 1e0595885a811e3cf9a57e392f9b7e1b2dd618ee compression diff -r 1e0595885a81 -r 6d9be2b470b4 NEWS --- a/NEWS Fri Nov 30 14:37:48 2012 +0100 +++ b/NEWS Fri Nov 30 15:09:16 2012 +0100 @@ -4,12 +4,13 @@ Major changes ------------- -* Full refactoring of the DB schema and of the REST API -* Introduction of generic classes for REST APIs (in Core/RestApi) +* Transparent compression of the DICOM instances on the disk * The patient/study/series/instances are now indexed by SHA-1 digests of their DICOM Instance IDs (and not by UUIDs anymore): The same DICOM objects are thus always identified by the same Orthanc IDs * Log of exported instances through DICOM C-Store SCU ("/exported" URI) +* Full refactoring of the DB schema and of the REST API +* Introduction of generic classes for REST APIs (in Core/RestApi) Minor changes ------------- diff -r 1e0595885a81 -r 6d9be2b470b4 OrthancServer/ServerContext.cpp --- a/OrthancServer/ServerContext.cpp Fri Nov 30 14:37:48 2012 +0100 +++ b/OrthancServer/ServerContext.cpp Fri Nov 30 15:09:16 2012 +0100 @@ -55,6 +55,16 @@ { } + void ServerContext::SetCompressionEnabled(bool enabled) + { + if (enabled) + LOG(WARNING) << "Disk compression is enabled"; + else + LOG(WARNING) << "Disk compression is disabled"; + + compressionEnabled_ = enabled; + } + void ServerContext::RemoveFile(const std::string& fileUuid) { storage_.Remove(fileUuid); @@ -66,7 +76,14 @@ const Json::Value& dicomJson, const std::string& remoteAet) { - //accessor_.SetCompressionForNextOperations(CompressionType_Zlib); + if (compressionEnabled_) + { + accessor_.SetCompressionForNextOperations(CompressionType_Zlib); + } + else + { + accessor_.SetCompressionForNextOperations(CompressionType_None); + } FileInfo dicomInfo = accessor_.Write(dicomFile, dicomSize, FileContentType_Dicom); FileInfo jsonInfo = accessor_.Write(dicomJson.toStyledString(), FileContentType_Json); @@ -107,16 +124,14 @@ FileContentType content) { FileInfo attachment; - if (index_.LookupAttachment(attachment, instancePublicId, FileContentType_Dicom)) + if (!index_.LookupAttachment(attachment, instancePublicId, content)) { - assert(attachment.GetCompressionType() == CompressionType_None); - assert(attachment.GetContentType() == FileContentType_Dicom); + throw OrthancException(ErrorCode_InternalError); + } - FilesystemHttpSender sender(storage_, attachment.GetUuid()); - sender.SetDownloadFilename(attachment.GetUuid() + ".dcm"); - sender.SetContentType("application/dicom"); - output.AnswerFile(sender); - } + accessor_.SetCompressionForNextOperations(attachment.GetCompressionType()); + std::auto_ptr sender(accessor_.ConstructHttpFileSender(attachment.GetUuid())); + output.AnswerFile(*sender); } diff -r 1e0595885a81 -r 6d9be2b470b4 OrthancServer/ServerContext.h --- a/OrthancServer/ServerContext.h Fri Nov 30 14:37:48 2012 +0100 +++ b/OrthancServer/ServerContext.h Fri Nov 30 15:09:16 2012 +0100 @@ -50,6 +50,7 @@ FileStorage storage_; ServerIndex index_; CompressedFileStorageAccessor accessor_; + bool compressionEnabled_; public: ServerContext(const boost::filesystem::path& path); @@ -59,6 +60,13 @@ return index_; } + void SetCompressionEnabled(bool enabled); + + bool IsCompressionEnabled() const + { + return compressionEnabled_; + } + void RemoveFile(const std::string& fileUuid); StoreStatus Store(const char* dicomFile, diff -r 1e0595885a81 -r 6d9be2b470b4 OrthancServer/main.cpp --- a/OrthancServer/main.cpp Fri Nov 30 14:37:48 2012 +0100 +++ b/OrthancServer/main.cpp Fri Nov 30 15:09:16 2012 +0100 @@ -212,6 +212,8 @@ boost::filesystem::path storageDirectory = GetGlobalStringParameter("StorageDirectory", "OrthancStorage"); ServerContext context(storageDirectory); + context.SetCompressionEnabled(GetGlobalBoolParameter("StorageCompression", false)); + MyDicomStoreFactory storeScp(context); { diff -r 1e0595885a81 -r 6d9be2b470b4 Resources/Configuration.json --- a/Resources/Configuration.json Fri Nov 30 14:37:48 2012 +0100 +++ b/Resources/Configuration.json Fri Nov 30 15:09:16 2012 +0100 @@ -3,12 +3,15 @@ * General configuration of Orthanc **/ + // The logical name of this instance of Orthanc. This one is + // displayed in Orthanc Explorer and at the URI "/system". + "Name" : "MyOrthanc", + // Path to the directory that holds the database "StorageDirectory" : "OrthancStorage", - // The logical name of this instance of Orthanc. This one is - // displayed in Orthanc Explorer and at the URI "/system". - "Name" : "MyOrthanc", + // Enable the transparent compression of the DICOM instances + "StorageCompression" : false,