From 78968c2e97a5c407a65088aa9861052d80498053 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Wed, 31 Jan 2024 10:31:00 +0100 Subject: improve oplog export logging (#644) - Improvement: More details in oplog import/export logs - Improvement: Switch from Download to Get when fetching Refs from Jupiter as they can't be resumed anyway and streaming to disk is redundant - Bugfix: Make sure we clear read callback when doing Put in HttpClient to avoid timeout due to not sending data when reusing sessions - Bugfix: Respect `--ignore-missing-attachments` in `oplog-export` command when loose file is missing on disk --- src/zenhttp/httpclient.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/zenhttp/httpclient.cpp') diff --git a/src/zenhttp/httpclient.cpp b/src/zenhttp/httpclient.cpp index c9005b1cf..cc8a3f033 100644 --- a/src/zenhttp/httpclient.cpp +++ b/src/zenhttp/httpclient.cpp @@ -210,10 +210,15 @@ struct HttpClient::Impl : public RefCounted ZEN_TRACE("HEAD {}", Result); return Result; } - inline cpr::Response Put() + inline cpr::Response Put(std::optional&& Read = {}) { + if (Read) + { + CprSession->SetReadCallback(std::move(Read.value())); + } cpr::Response Result = CprSession->Put(); ZEN_TRACE("PUT {}", Result); + CprSession->SetReadCallback({}); return Result; } inline cpr::Response Post() @@ -790,12 +795,9 @@ HttpClient::Upload(std::string_view Url, const IoBuffer& Payload, const KeyValue Offset += size; return true; }; - Sess->SetReadCallback(cpr::ReadCallback(gsl::narrow(Payload.GetSize()), ReadCallback)); - } - else - { - Sess->SetBody(AsCprBody(Payload)); + return Sess.Put(cpr::ReadCallback(gsl::narrow(Payload.GetSize()), ReadCallback)); } + Sess->SetBody(AsCprBody(Payload)); return Sess.Put(); }, m_ConnectionSettings.RetryCount)); @@ -821,9 +823,7 @@ HttpClient::Upload(std::string_view Url, const CompositeBuffer& Payload, ZenCont SizeLeft -= size; return true; }; - Sess->SetReadCallback(cpr::ReadCallback(gsl::narrow(Payload.GetSize()), ReadCallback)); - - return Sess.Put(); + return Sess.Put(cpr::ReadCallback(gsl::narrow(Payload.GetSize()), ReadCallback)); }, m_ConnectionSettings.RetryCount)); } -- cgit v1.2.3