diff --git a/src/hydra-queue-runner/nar-extractor.cc b/src/hydra-queue-runner/nar-extractor.cc index 31c0db65..7619b2ee 100644 --- a/src/hydra-queue-runner/nar-extractor.cc +++ b/src/hydra-queue-runner/nar-extractor.cc @@ -11,29 +11,28 @@ struct Extractor : NARParseVisitor { class MyFileHandle : public FileHandle { - NarMemberData * memberData; + NarMemberData & memberData; uint64_t expectedSize; std::unique_ptr hashSink; public: - MyFileHandle(NarMemberData * memberData, uint64_t size) : memberData(memberData) + MyFileHandle(NarMemberData & memberData, uint64_t size) : memberData(memberData), expectedSize(size) { - expectedSize = size; hashSink = std::make_unique(HashType::SHA256); } void receiveContents(std::string_view data) override { - *memberData->fileSize += data.size(); + *memberData.fileSize += data.size(); (*hashSink)(data); - if (memberData->contents) { - memberData->contents->append(data); + if (memberData.contents) { + memberData.contents->append(data); } - assert(memberData->fileSize <= expectedSize); - if (memberData->fileSize == expectedSize) { + assert(memberData.fileSize <= expectedSize); + if (memberData.fileSize == expectedSize) { auto [hash, len] = hashSink->finish(); - assert(memberData->fileSize == len); - memberData->sha256 = hash; + assert(memberData.fileSize == len); + memberData.sha256 = hash; hashSink.reset(); } } @@ -65,7 +64,7 @@ struct Extractor : NARParseVisitor .contents = filesToKeep.count(path) ? std::optional("") : std::nullopt, }).first->second; - return std::unique_ptr(new MyFileHandle{memberData, size}); + return std::make_unique(*memberData, size); } void createSymlink(const Path & path, const std::string & target) override