binary-cache-store: UpsertFile accept Source & instead of std::istream
This commit is contained in:
committed by
John Ericson
parent
e3c41407f9
commit
e947c895ec
@@ -79,7 +79,8 @@ std::optional<std::string> BinaryCacheStore::getNixCacheInfo()
|
||||
void BinaryCacheStore::upsertFile(
|
||||
const std::string & path, std::string && data, const std::string & mimeType, uint64_t sizeHint)
|
||||
{
|
||||
upsertFile(path, std::make_shared<std::stringstream>(std::move(data)), mimeType, sizeHint);
|
||||
StringSource source{data};
|
||||
upsertFile(path, source, mimeType, sizeHint);
|
||||
}
|
||||
|
||||
void BinaryCacheStore::getFile(const std::string & path, Callback<std::optional<std::string>> callback) noexcept
|
||||
@@ -271,12 +272,10 @@ ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
|
||||
|
||||
/* Atomically write the NAR file. */
|
||||
if (repair || !fileExists(narInfo->url)) {
|
||||
AutoCloseFD fd = toDescriptor(open(fnTemp.c_str(), O_RDONLY));
|
||||
FdSource source{fd.get()};
|
||||
stats.narWrite++;
|
||||
upsertFile(
|
||||
narInfo->url,
|
||||
std::make_shared<std::fstream>(fnTemp, std::ios_base::in | std::ios_base::binary),
|
||||
"application/x-nix-nar",
|
||||
narInfo->fileSize);
|
||||
upsertFile(narInfo->url, source, "application/x-nix-nar", narInfo->fileSize);
|
||||
} else
|
||||
stats.narWriteAverted++;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user