comparison OrthancServer/Sources/OrthancWebDav.cpp @ 4508:8f9090b137f1

Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 11 Feb 2021 11:00:05 +0100
parents 6831de40acd9
children 350a22c094f2
comparison
equal deleted inserted replaced
4507:b4c58795f3a8 4508:8f9090b137f1
1280 { 1280 {
1281 if (!uncompressedFile.empty()) 1281 if (!uncompressedFile.empty())
1282 { 1282 {
1283 LOG(INFO) << "Uploading DICOM file extracted from a ZIP archive in WebDAV: " << filename; 1283 LOG(INFO) << "Uploading DICOM file extracted from a ZIP archive in WebDAV: " << filename;
1284 1284
1285 DicomInstanceToStore instance; 1285 std::unique_ptr<DicomInstanceToStore> instance(DicomInstanceToStore::CreateFromBuffer(uncompressedFile));
1286 instance.SetOrigin(DicomInstanceOrigin::FromWebDav()); 1286 instance->SetOrigin(DicomInstanceOrigin::FromWebDav());
1287 instance.SetBuffer(uncompressedFile.c_str(), uncompressedFile.size());
1288 1287
1289 std::string publicId; 1288 std::string publicId;
1290 1289
1291 try 1290 try
1292 { 1291 {
1293 context_.Store(publicId, instance, StoreInstanceMode_Default); 1292 context_.Store(publicId, *instance, StoreInstanceMode_Default);
1294 } 1293 }
1295 catch (OrthancException& e) 1294 catch (OrthancException& e)
1296 { 1295 {
1297 if (e.GetErrorCode() == ErrorCode_BadFileFormat) 1296 if (e.GetErrorCode() == ErrorCode_BadFileFormat)
1298 { 1297 {
1304 1303
1305 success = true; 1304 success = true;
1306 } 1305 }
1307 else 1306 else
1308 { 1307 {
1309 DicomInstanceToStore instance; 1308 std::unique_ptr<DicomInstanceToStore> instance(DicomInstanceToStore::CreateFromBuffer(content));
1310 instance.SetOrigin(DicomInstanceOrigin::FromWebDav()); 1309 instance->SetOrigin(DicomInstanceOrigin::FromWebDav());
1311 instance.SetBuffer(content.c_str(), content.size());
1312 1310
1313 try 1311 try
1314 { 1312 {
1315 std::string publicId; 1313 std::string publicId;
1316 StoreStatus status = context_.Store(publicId, instance, StoreInstanceMode_Default); 1314 StoreStatus status = context_.Store(publicId, *instance, StoreInstanceMode_Default);
1317 if (status == StoreStatus_Success || 1315 if (status == StoreStatus_Success ||
1318 status == StoreStatus_AlreadyStored) 1316 status == StoreStatus_AlreadyStored)
1319 { 1317 {
1320 LOG(INFO) << "Successfully imported DICOM instance from WebDAV: " 1318 LOG(INFO) << "Successfully imported DICOM instance from WebDAV: "
1321 << path << " (Orthanc ID: " << publicId << ")"; 1319 << path << " (Orthanc ID: " << publicId << ")";