Mercurial > hg > orthanc
diff 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 |
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerJobs/ArchiveJob.cpp Thu Dec 03 15:58:52 2020 +0100 +++ b/OrthancServer/Sources/ServerJobs/ArchiveJob.cpp Thu Dec 03 18:15:47 2020 +0100 @@ -56,6 +56,7 @@ static const char* const KEY_DESCRIPTION = "Description"; static const char* const KEY_INSTANCES_COUNT = "InstancesCount"; static const char* const KEY_UNCOMPRESSED_SIZE_MB = "UncompressedSizeMB"; +static const char* const KEY_ARCHIVE_SIZE_MB = "ArchiveSizeMB"; static const char* const KEY_TRANSCODE = "Transcode"; @@ -851,6 +852,7 @@ currentStep_(0), instancesCount_(0), uncompressedSize_(0), + archiveSize_(0), transcode_(false), transferSyntax_(DicomTransferSyntax_LittleEndianImplicit) { @@ -993,10 +995,26 @@ } + void ArchiveJob::RefreshArchiveSize() + { + if (synchronousTarget_.get() != NULL) + { + archiveSize_ = synchronousTarget_->GetFileSize(); + } + + if (asynchronousTarget_.get() != NULL) + { + archiveSize_ = asynchronousTarget_->GetFileSize(); + } + } + + void ArchiveJob::FinalizeTarget() { writer_.reset(); // Flush all the results + RefreshArchiveSize(); + if (asynchronousTarget_.get() != NULL) { // Asynchronous behavior: Move the resulting file into the media archive @@ -1017,7 +1035,7 @@ return JobStepResult::Failure(ErrorCode_NetworkProtocol, "A client has disconnected while creating an archive"); } - + if (writer_->GetStepsCount() == 0) { FinalizeTarget(); @@ -1036,6 +1054,7 @@ } else { + RefreshArchiveSize(); return JobStepResult::Continue(); } } @@ -1077,6 +1096,8 @@ value[KEY_INSTANCES_COUNT] = instancesCount_; value[KEY_UNCOMPRESSED_SIZE_MB] = static_cast<unsigned int>(uncompressedSize_ / MEGA_BYTES); + value[KEY_ARCHIVE_SIZE_MB] = + static_cast<unsigned int>(archiveSize_ / MEGA_BYTES); if (transcode_) {