comparison Common/StoragePlugin.cpp @ 121:addccb7ad900 2.3.0

rollback e39aa88ec20e commited in wrong branch
author Alain Mazy <am@osimis.io>
date Tue, 21 Nov 2023 09:50:24 +0100
parents e39aa88ec20e
children df0b6998fd27
comparison
equal deleted inserted replaced
119:e39aa88ec20e 121:addccb7ad900
86 int64_t size, 86 int64_t size,
87 OrthancPluginContentType type) 87 OrthancPluginContentType type)
88 { 88 {
89 try 89 try
90 { 90 {
91 Orthanc::Toolbox::ElapsedTimer timer;
92 OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": creating attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); 91 OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": creating attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
93 std::unique_ptr<IStorage::IWriter> writer(primaryStorage->GetWriterForObject(uuid, type, cryptoEnabled)); 92 std::unique_ptr<IStorage::IWriter> writer(primaryStorage->GetWriterForObject(uuid, type, cryptoEnabled));
94 93
95 if (cryptoEnabled) 94 if (cryptoEnabled)
96 { 95 {
110 } 109 }
111 else 110 else
112 { 111 {
113 writer->Write(reinterpret_cast<const char*>(content), size); 112 writer->Write(reinterpret_cast<const char*>(content), size);
114 } 113 }
115 OrthancPlugins::LogInfo(primaryStorage->GetNameForLogs() + ": created attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, size) + ")");
116 } 114 }
117 catch (StoragePluginException& ex) 115 catch (StoragePluginException& ex)
118 { 116 {
119 OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while creating object " + std::string(uuid) + ": " + ex.what()); 117 OrthancPlugins::LogError(primaryStorage->GetNameForLogs() + ": error while creating object " + std::string(uuid) + ": " + ex.what());
120 return OrthancPluginErrorCode_StorageAreaPlugin; 118 return OrthancPluginErrorCode_StorageAreaPlugin;
133 { 131 {
134 assert(!cryptoEnabled); 132 assert(!cryptoEnabled);
135 133
136 try 134 try
137 { 135 {
138 Orthanc::Toolbox::ElapsedTimer timer;
139 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading range of attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); 136 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading range of attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
140 137
141 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled)); 138 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled));
142 reader->ReadRange(reinterpret_cast<char*>(target->data), target->size, rangeStart); 139 reader->ReadRange(reinterpret_cast<char*>(target->data), target->size, rangeStart);
143 140
144 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": read range of attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, target->size) + ")");
145 return OrthancPluginErrorCode_Success; 141 return OrthancPluginErrorCode_Success;
146 } 142 }
147 catch (StoragePluginException& ex) 143 catch (StoragePluginException& ex)
148 { 144 {
149 logErrorFunction(std::string(StoragePluginFactory::GetStoragePluginName()) + ": error while reading object " + std::string(uuid) + ": " + std::string(ex.what())); 145 logErrorFunction(std::string(StoragePluginFactory::GetStoragePluginName()) + ": error while reading object " + std::string(uuid) + ": " + std::string(ex.what()));
183 const char* uuid, 179 const char* uuid,
184 OrthancPluginContentType type) 180 OrthancPluginContentType type)
185 { 181 {
186 try 182 try
187 { 183 {
188 Orthanc::Toolbox::ElapsedTimer timer;
189 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading whole attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type)); 184 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": reading whole attachment " + std::string(uuid) + " of type " + boost::lexical_cast<std::string>(type));
190 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled)); 185 std::unique_ptr<IStorage::IReader> reader(storage->GetReaderForObject(uuid, type, cryptoEnabled));
191 186
192 size_t fileSize = reader->GetSize(); 187 size_t fileSize = reader->GetSize();
193 size_t size; 188 size_t size;
230 } 225 }
231 else 226 else
232 { 227 {
233 reader->ReadWhole(reinterpret_cast<char*>(target->data), fileSize); 228 reader->ReadWhole(reinterpret_cast<char*>(target->data), fileSize);
234 } 229 }
235
236 OrthancPlugins::LogInfo(storage->GetNameForLogs() + ": read whole attachment " + std::string(uuid) + " (" + timer.GetHumanTransferSpeed(true, fileSize) + ")");
237 } 230 }
238 catch (StoragePluginException& ex) 231 catch (StoragePluginException& ex)
239 { 232 {
240 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ": " + ex.what()); 233 logErrorFunction(storage->GetNameForLogs() + ": error while reading object " + std::string(uuid) + ": " + ex.what());
241 return OrthancPluginErrorCode_StorageAreaPlugin; 234 return OrthancPluginErrorCode_StorageAreaPlugin;