fix build with latest lix #10

Closed
yu-re-ka wants to merge 1 commit from lix-update into main
2 changed files with 30 additions and 29 deletions
Showing only changes of commit f037de5ad8 - Show all commits

View file

@ -185,7 +185,7 @@ State::StepResult State::doBuildStep(nix::ref<Store> destStore,
unlink(result.logFile.c_str()); unlink(result.logFile.c_str());
} }
} catch (...) { } catch (...) {
ignoreException(); ignoreExceptionExceptInterrupt();
} }
} }
}); });

View file

@ -7,7 +7,7 @@
using namespace nix; using namespace nix;
struct Extractor : ParseSink struct Extractor : NARParseVisitor
{ {
std::unordered_set<Path> filesToKeep { std::unordered_set<Path> filesToKeep {
"/nix-support/hydra-build-products", "/nix-support/hydra-build-products",
@ -16,7 +16,6 @@ struct Extractor : ParseSink
}; };
NarMemberDatas & members; NarMemberDatas & members;
NarMemberData * curMember = nullptr;
Path prefix; Path prefix;
Extractor(NarMemberDatas & members, 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 }); members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tDirectory });
} }
void createRegularFile(const Path & path) override std::unique_ptr<FileHandle> 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, .type = FSAccessor::Type::tRegular,
.fileSize = 0, .fileSize = 0,
.contents = filesToKeep.count(path) ? std::optional("") : std::nullopt, .contents = filesToKeep.count(path) ? std::optional("") : std::nullopt,
}).first->second; }).first->second;
hdl->expectedSize = size;
hdl->hashSink = std::make_unique<HashSink>(HashType::SHA256);
return std::unique_ptr<MyFileHandle>(hdl);
} }
std::optional<uint64_t> expectedSize; struct MyFileHandle : public FileHandle
std::unique_ptr<HashSink> hashSink;
void preallocateContents(uint64_t size) override
{ {
expectedSize = size; uint64_t expectedSize;
hashSink = std::make_unique<HashSink>(HashType::SHA256); std::unique_ptr<HashSink> hashSink;
} NarMemberData * memberData;
void receiveContents(std::string_view data) override void receiveContents(std::string_view data) override
{ {
assert(expectedSize); *memberData->fileSize += data.size();
assert(curMember); (*hashSink)(data);
assert(hashSink); if (memberData->contents) {
*curMember->fileSize += data.size(); memberData->contents->append(data);
(*hashSink)(data); }
if (curMember->contents) { assert(memberData->fileSize <= expectedSize);
curMember->contents->append(data); 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 void createSymlink(const Path & path, const std::string & target) override
{ {