1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-20 17:29:36 +01:00

binary-cache-store: UpsertFile accept Source & instead of std::istream

This commit is contained in:
Sergei Zimmerman 2025-10-28 03:02:02 +03:00 committed by John Ericson
parent e3c41407f9
commit e947c895ec
6 changed files with 16 additions and 38 deletions

View file

@ -53,17 +53,12 @@ protected:
bool fileExists(const std::string & path) override;
void upsertFile(
const std::string & path,
std::shared_ptr<std::basic_iostream<char>> istream,
const std::string & mimeType,
uint64_t sizeHint) override
void upsertFile(const std::string & path, Source & source, const std::string & mimeType, uint64_t sizeHint) override
{
auto path2 = config->binaryCacheDir + "/" + path;
static std::atomic<int> counter{0};
Path tmp = fmt("%s.tmp.%d.%d", path2, getpid(), ++counter);
AutoDelete del(tmp, false);
StreamToSourceAdapter source(istream);
writeFile(tmp, source);
std::filesystem::rename(tmp, path2);
del.cancel();