From f037de5ad8129c1d9aead55bd7ffc9b3813ca45e Mon Sep 17 00:00:00 2001 From: Yureka Date: Sun, 6 Oct 2024 13:50:15 +0200 Subject: [PATCH] fix build with latest lix --- src/hydra-queue-runner/builder.cc | 2 +- src/hydra-queue-runner/nar-extractor.cc | 57 +++++++++++++------------ 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/hydra-queue-runner/builder.cc b/src/hydra-queue-runner/builder.cc index 3f340c72..42b2b49e 100644 --- a/src/hydra-queue-runner/builder.cc +++ b/src/hydra-queue-runner/builder.cc @@ -185,7 +185,7 @@ State::StepResult State::doBuildStep(nix::ref destStore, unlink(result.logFile.c_str()); } } catch (...) { - ignoreException(); + ignoreExceptionExceptInterrupt(); } } }); diff --git a/src/hydra-queue-runner/nar-extractor.cc b/src/hydra-queue-runner/nar-extractor.cc index b3350193..df0d94e3 100644 --- a/src/hydra-queue-runner/nar-extractor.cc +++ b/src/hydra-queue-runner/nar-extractor.cc @@ -7,7 +7,7 @@ using namespace nix; -struct Extractor : ParseSink +struct Extractor : NARParseVisitor { std::unordered_set filesToKeep { "/nix-support/hydra-build-products", @@ -16,7 +16,6 @@ struct Extractor : ParseSink }; NarMemberDatas & members; - NarMemberData * curMember = nullptr; Path prefix; Extractor(NarMemberDatas & members, Path prefix) @@ -28,42 +27,44 @@ struct Extractor : ParseSink members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tDirectory }); } - void createRegularFile(const Path & path) override + std::unique_ptr createRegularFile(const Path & path, uint64_t size, bool executable) override { - curMember = &members.insert_or_assign(prefix + path, NarMemberData { + MyFileHandle * hdl = new MyFileHandle(); + + hdl->memberData = &members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tRegular, .fileSize = 0, .contents = filesToKeep.count(path) ? std::optional("") : std::nullopt, }).first->second; + + hdl->expectedSize = size; + hdl->hashSink = std::make_unique(HashType::SHA256); + + return std::unique_ptr(hdl); } - std::optional expectedSize; - std::unique_ptr hashSink; - - void preallocateContents(uint64_t size) override + struct MyFileHandle : public FileHandle { - expectedSize = size; - hashSink = std::make_unique(HashType::SHA256); - } + uint64_t expectedSize; + std::unique_ptr hashSink; + NarMemberData * memberData; - void receiveContents(std::string_view data) override - { - assert(expectedSize); - assert(curMember); - assert(hashSink); - *curMember->fileSize += data.size(); - (*hashSink)(data); - if (curMember->contents) { - curMember->contents->append(data); + void receiveContents(std::string_view data) override + { + *memberData->fileSize += data.size(); + (*hashSink)(data); + if (memberData->contents) { + memberData->contents->append(data); + } + assert(memberData->fileSize <= expectedSize); + if (memberData->fileSize == expectedSize) { + auto [hash, len] = hashSink->finish(); + assert(memberData->fileSize == len); + memberData->sha256 = hash; + hashSink.reset(); + } } - assert(curMember->fileSize <= expectedSize); - if (curMember->fileSize == expectedSize) { - auto [hash, len] = hashSink->finish(); - assert(curMember->fileSize == len); - curMember->sha256 = hash; - hashSink.reset(); - } - } + }; void createSymlink(const Path & path, const std::string & target) override {