Mercurial > hg > orthanc
diff OrthancServer/ServerContext.cpp @ 236:6d9be2b470b4
compression
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 30 Nov 2012 15:09:16 +0100 |
parents | c11273198cef |
children | f6fdf5abe751 |
line wrap: on
line diff
--- 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<HttpFileSender> sender(accessor_.ConstructHttpFileSender(attachment.GetUuid())); + output.AnswerFile(*sender); }