Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerJobs/ArchiveJob.cpp @ 4341:977c2759eb0a
Archive/media jobs report the size of the created ZIP file in content field "ArchiveSizeMB"
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 03 Dec 2020 18:15:47 +0100 |
parents | d962a2996637 |
children | d9473bd5ed43 |
comparison
equal
deleted
inserted
replaced
4340:6fa8bb987be2 | 4341:977c2759eb0a |
---|---|
54 | 54 |
55 static const char* const MEDIA_IMAGES_FOLDER = "IMAGES"; | 55 static const char* const MEDIA_IMAGES_FOLDER = "IMAGES"; |
56 static const char* const KEY_DESCRIPTION = "Description"; | 56 static const char* const KEY_DESCRIPTION = "Description"; |
57 static const char* const KEY_INSTANCES_COUNT = "InstancesCount"; | 57 static const char* const KEY_INSTANCES_COUNT = "InstancesCount"; |
58 static const char* const KEY_UNCOMPRESSED_SIZE_MB = "UncompressedSizeMB"; | 58 static const char* const KEY_UNCOMPRESSED_SIZE_MB = "UncompressedSizeMB"; |
59 static const char* const KEY_ARCHIVE_SIZE_MB = "ArchiveSizeMB"; | |
59 static const char* const KEY_TRANSCODE = "Transcode"; | 60 static const char* const KEY_TRANSCODE = "Transcode"; |
60 | 61 |
61 | 62 |
62 namespace Orthanc | 63 namespace Orthanc |
63 { | 64 { |
849 isMedia_(isMedia), | 850 isMedia_(isMedia), |
850 enableExtendedSopClass_(enableExtendedSopClass), | 851 enableExtendedSopClass_(enableExtendedSopClass), |
851 currentStep_(0), | 852 currentStep_(0), |
852 instancesCount_(0), | 853 instancesCount_(0), |
853 uncompressedSize_(0), | 854 uncompressedSize_(0), |
855 archiveSize_(0), | |
854 transcode_(false), | 856 transcode_(false), |
855 transferSyntax_(DicomTransferSyntax_LittleEndianImplicit) | 857 transferSyntax_(DicomTransferSyntax_LittleEndianImplicit) |
856 { | 858 { |
857 } | 859 } |
858 | 860 |
991 } | 993 } |
992 }; | 994 }; |
993 } | 995 } |
994 | 996 |
995 | 997 |
998 void ArchiveJob::RefreshArchiveSize() | |
999 { | |
1000 if (synchronousTarget_.get() != NULL) | |
1001 { | |
1002 archiveSize_ = synchronousTarget_->GetFileSize(); | |
1003 } | |
1004 | |
1005 if (asynchronousTarget_.get() != NULL) | |
1006 { | |
1007 archiveSize_ = asynchronousTarget_->GetFileSize(); | |
1008 } | |
1009 } | |
1010 | |
1011 | |
996 void ArchiveJob::FinalizeTarget() | 1012 void ArchiveJob::FinalizeTarget() |
997 { | 1013 { |
998 writer_.reset(); // Flush all the results | 1014 writer_.reset(); // Flush all the results |
999 | 1015 |
1016 RefreshArchiveSize(); | |
1017 | |
1000 if (asynchronousTarget_.get() != NULL) | 1018 if (asynchronousTarget_.get() != NULL) |
1001 { | 1019 { |
1002 // Asynchronous behavior: Move the resulting file into the media archive | 1020 // Asynchronous behavior: Move the resulting file into the media archive |
1003 mediaArchiveId_ = context_.GetMediaArchive().Add( | 1021 mediaArchiveId_ = context_.GetMediaArchive().Add( |
1004 new DynamicTemporaryFile(asynchronousTarget_.release())); | 1022 new DynamicTemporaryFile(asynchronousTarget_.release())); |
1015 { | 1033 { |
1016 LOG(WARNING) << "A client has disconnected while creating an archive"; | 1034 LOG(WARNING) << "A client has disconnected while creating an archive"; |
1017 return JobStepResult::Failure(ErrorCode_NetworkProtocol, | 1035 return JobStepResult::Failure(ErrorCode_NetworkProtocol, |
1018 "A client has disconnected while creating an archive"); | 1036 "A client has disconnected while creating an archive"); |
1019 } | 1037 } |
1020 | 1038 |
1021 if (writer_->GetStepsCount() == 0) | 1039 if (writer_->GetStepsCount() == 0) |
1022 { | 1040 { |
1023 FinalizeTarget(); | 1041 FinalizeTarget(); |
1024 return JobStepResult::Success(); | 1042 return JobStepResult::Success(); |
1025 } | 1043 } |
1034 FinalizeTarget(); | 1052 FinalizeTarget(); |
1035 return JobStepResult::Success(); | 1053 return JobStepResult::Success(); |
1036 } | 1054 } |
1037 else | 1055 else |
1038 { | 1056 { |
1057 RefreshArchiveSize(); | |
1039 return JobStepResult::Continue(); | 1058 return JobStepResult::Continue(); |
1040 } | 1059 } |
1041 } | 1060 } |
1042 } | 1061 } |
1043 | 1062 |
1075 value = Json::objectValue; | 1094 value = Json::objectValue; |
1076 value[KEY_DESCRIPTION] = description_; | 1095 value[KEY_DESCRIPTION] = description_; |
1077 value[KEY_INSTANCES_COUNT] = instancesCount_; | 1096 value[KEY_INSTANCES_COUNT] = instancesCount_; |
1078 value[KEY_UNCOMPRESSED_SIZE_MB] = | 1097 value[KEY_UNCOMPRESSED_SIZE_MB] = |
1079 static_cast<unsigned int>(uncompressedSize_ / MEGA_BYTES); | 1098 static_cast<unsigned int>(uncompressedSize_ / MEGA_BYTES); |
1099 value[KEY_ARCHIVE_SIZE_MB] = | |
1100 static_cast<unsigned int>(archiveSize_ / MEGA_BYTES); | |
1080 | 1101 |
1081 if (transcode_) | 1102 if (transcode_) |
1082 { | 1103 { |
1083 value[KEY_TRANSCODE] = GetTransferSyntaxUid(transferSyntax_); | 1104 value[KEY_TRANSCODE] = GetTransferSyntaxUid(transferSyntax_); |
1084 } | 1105 } |