aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-08-09 10:38:01 +0200
committerGitHub <[email protected]>2023-08-09 10:38:01 +0200
commit5d8979b00ef10728679bc3fadf3708afec319806 (patch)
tree5fe1862279cab0a0505498bdaef1803d11398a64 /src
parentBugfix: `oplog-import` with `--file` source now sends the oplog folder correc... (diff)
downloadzen-5d8979b00ef10728679bc3fadf3708afec319806.tar.xz
zen-5d8979b00ef10728679bc3fadf3708afec319806.zip
use streaming read for PutCompressedBlob if source is single file (#338)
* use streaming read for PutCompressedBlob if source is single file * changelog
Diffstat (limited to 'src')
-rw-r--r--src/zenserver/upstream/jupiter.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/zenserver/upstream/jupiter.cpp b/src/zenserver/upstream/jupiter.cpp
index 32537508c..e7bb2cbcf 100644
--- a/src/zenserver/upstream/jupiter.cpp
+++ b/src/zenserver/upstream/jupiter.cpp
@@ -445,7 +445,24 @@ CloudCacheSession::PutCompressedBlob(std::string_view Namespace, const IoHash& K
Session.SetOption(cpr::Url{Uri.c_str()});
Session.SetOption(cpr::Header{{"Authorization", AccessToken.Value}, {"Content-Type", "application/x-ue-comp"}});
- Session.SetBody(cpr::Body{(const char*)Blob.Data(), Blob.Size()});
+
+ uint64_t Offset = 0;
+ if (Blob.IsWholeFile())
+ {
+ auto ReadCallback = [&Blob, &Offset](char* buffer, size_t& size, intptr_t) {
+ size = Min<size_t>(size, Blob.GetSize() - Offset);
+ IoBuffer PayloadRange = IoBuffer(Blob, Offset, size);
+ MutableMemoryView Data(buffer, size);
+ Data.CopyFrom(PayloadRange.GetView());
+ Offset += size;
+ return true;
+ };
+ Session.SetReadCallback(cpr::ReadCallback(gsl::narrow<cpr::cpr_off_t>(Blob.GetSize()), ReadCallback));
+ }
+ else
+ {
+ Session.SetBody(cpr::Body{(const char*)Blob.Data(), Blob.Size()});
+ }
cpr::Response Response = Session.Put();
ZEN_DEBUG("PUT {}", Response);