aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/s3-binary-cache-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-08-04 16:00:59 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-08-04 16:01:13 +0200
commit4e7f1c7f11fb22d7954b2dacbe87c61548fab82d (patch)
tree9c8d67e9c80bf3f0a81a5541b01b6291d29e90e2 /src/libstore/s3-binary-cache-store.cc
parentdfe66420e7e5395acfa8068fafcadc3a38a56184 (diff)
S3BinaryCacheStore: Fix size determination
Diffstat (limited to 'src/libstore/s3-binary-cache-store.cc')
-rw-r--r--src/libstore/s3-binary-cache-store.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc
index 1b7dff085..a0a446bd3 100644
--- a/src/libstore/s3-binary-cache-store.cc
+++ b/src/libstore/s3-binary-cache-store.cc
@@ -266,6 +266,10 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore
const std::string & mimeType,
const std::string & contentEncoding)
{
+ istream->seekg(0, istream->end);
+ auto size = istream->tellg();
+ istream->seekg(0, istream->beg);
+
auto maxThreads = std::thread::hardware_concurrency();
static std::shared_ptr<Aws::Utils::Threading::PooledThreadExecutor>
@@ -343,13 +347,11 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore
std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1)
.count();
- auto size = istream->tellg();
-
printInfo("uploaded 's3://%s/%s' (%d bytes) in %d ms",
bucketName, path, size, duration);
stats.putTimeMs += duration;
- stats.putBytes += size;
+ stats.putBytes += std::max(size, (decltype(size)) 0);
stats.put++;
}