diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-07-13 20:07:19 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-07-13 20:07:19 +0200 |
commit | 7c2fef0a819481058d49c469c115bb0668b7016b (patch) | |
tree | 527d061e600b23d6922a4daf6609bc247e992186 /src/libstore/binary-cache-store.cc | |
parent | 493961b6899e7f3471e7efa24ed251c7723adbcd (diff) |
Make 'nix copy' to s3:// binary caches run in constant memory
Diffstat (limited to 'src/libstore/binary-cache-store.cc')
-rw-r--r-- | src/libstore/binary-cache-store.cc | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libstore/binary-cache-store.cc b/src/libstore/binary-cache-store.cc index e71240558..b791c125b 100644 --- a/src/libstore/binary-cache-store.cc +++ b/src/libstore/binary-cache-store.cc @@ -15,6 +15,7 @@ #include <chrono> #include <future> #include <regex> +#include <fstream> #include <nlohmann/json.hpp> @@ -58,11 +59,10 @@ void BinaryCacheStore::init() } void BinaryCacheStore::upsertFile(const std::string & path, - const std::string & data, + std::string && data, const std::string & mimeType) { - StringSource source(data); - upsertFile(path, source, mimeType); + upsertFile(path, std::make_shared<std::stringstream>(std::move(data)), mimeType); } void BinaryCacheStore::getFile(const std::string & path, @@ -279,8 +279,9 @@ void BinaryCacheStore::addToStore(const ValidPathInfo & info, Source & narSource /* Atomically write the NAR file. */ if (repair || !fileExists(narInfo->url)) { stats.narWrite++; - FileSource source(fnTemp); - upsertFile(narInfo->url, source, "application/x-nix-nar"); + upsertFile(narInfo->url, + std::make_shared<std::fstream>(fnTemp, std::ios_base::in), + "application/x-nix-nar"); } else stats.narWriteAverted++; |