From 30bec83fa482f87cb55c355b06bbe78d67889d92 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Sun, 27 Oct 2024 18:27:11 +0100 Subject: [PATCH] libstore: remove FileTransferResult::bodySize it's only used for internal bookkeeping in TransferItem. Change-Id: I467c5be023488be4a8a76e5f98a4ef25762df6f3 --- src/libstore/filetransfer.cc | 11 ++++++----- src/libstore/filetransfer.hh | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index f4ce04081..fc1353349 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -58,6 +58,7 @@ struct curlFileTransfer : public FileTransfer unsigned int attempt = 0; const size_t tries = fileTransferSettings.tries; + uint64_t bodySize = 0; /* Don't start this download until the specified time point has been reached. */ @@ -153,7 +154,7 @@ struct curlFileTransfer : public FileTransfer const size_t realSize = size * nmemb; try { - result.bodySize += realSize; + bodySize += realSize; if (successfulStatuses.count(getHTTPStatus()) && this->dataCallback) { writtenToSink += realSize; @@ -184,7 +185,7 @@ struct curlFileTransfer : public FileTransfer if (std::smatch match; std::regex_match(line, match, statusLine)) { result.etag = ""; result.data.clear(); - result.bodySize = 0; + bodySize = 0; statusMsg = trim(match.str(1)); acceptRanges = false; encoding = ""; @@ -329,7 +330,7 @@ struct curlFileTransfer : public FileTransfer curl_easy_setopt(req, CURLOPT_RESUME_FROM_LARGE, writtenToSink); result.data.clear(); - result.bodySize = 0; + bodySize = 0; } void finish(CURLcode code) @@ -342,7 +343,7 @@ struct curlFileTransfer : public FileTransfer result.effectiveUri = effectiveUriCStr; debug("finished %s of '%s'; curl status = %d, HTTP status = %d, body = %d bytes", - verb(), request.uri, code, httpStatus, result.bodySize); + verb(), request.uri, code, httpStatus, bodySize); // this has to happen here until we can return an actual future. // wrapping user `callback`s instead is not possible because the @@ -358,7 +359,7 @@ struct curlFileTransfer : public FileTransfer else if (code == CURLE_OK && successfulStatuses.count(httpStatus)) { result.cached = httpStatus == 304; - act.progress(result.bodySize, result.bodySize); + act.progress(bodySize, bodySize); done = true; callback(nullptr, std::move(result)); } diff --git a/src/libstore/filetransfer.hh b/src/libstore/filetransfer.hh index 86c772fb1..ed22578a2 100644 --- a/src/libstore/filetransfer.hh +++ b/src/libstore/filetransfer.hh @@ -68,7 +68,6 @@ struct FileTransferResult std::string etag; std::string effectiveUri; std::string data; - uint64_t bodySize = 0; /* An "immutable" URL for this resource (i.e. one whose contents will never change), as returned by the `Link: ; rel="immutable"` header. */