Revert "fix build with latest lix"

This reverts commit f037de5ad8.
This commit is contained in:
Yureka 2024-10-06 13:54:13 +02:00
parent f037de5ad8
commit 67421f8eaa
2 changed files with 30 additions and 31 deletions

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 (...) {
ignoreExceptionExceptInterrupt(); ignoreException();
} }
} }
}); });

View file

@ -7,7 +7,7 @@
using namespace nix; using namespace nix;
struct Extractor : NARParseVisitor struct Extractor : ParseSink
{ {
std::unordered_set<Path> filesToKeep { std::unordered_set<Path> filesToKeep {
"/nix-support/hydra-build-products", "/nix-support/hydra-build-products",
@ -16,6 +16,7 @@ struct Extractor : NARParseVisitor
}; };
NarMemberDatas & members; NarMemberDatas & members;
NarMemberData * curMember = nullptr;
Path prefix; Path prefix;
Extractor(NarMemberDatas & members, Path prefix) Extractor(NarMemberDatas & members, Path prefix)
@ -27,44 +28,42 @@ struct Extractor : NARParseVisitor
members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tDirectory }); members.insert_or_assign(prefix + path, NarMemberData { .type = FSAccessor::Type::tDirectory });
} }
std::unique_ptr<FileHandle> createRegularFile(const Path & path, uint64_t size, bool executable) override void createRegularFile(const Path & path) override
{ {
MyFileHandle * hdl = new MyFileHandle(); curMember = &members.insert_or_assign(prefix + path, NarMemberData {
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);
} }
struct MyFileHandle : public FileHandle std::optional<uint64_t> expectedSize;
{ std::unique_ptr<HashSink> hashSink;
uint64_t expectedSize;
std::unique_ptr<HashSink> hashSink;
NarMemberData * memberData;
void receiveContents(std::string_view data) override void preallocateContents(uint64_t size) override
{ {
*memberData->fileSize += data.size(); expectedSize = size;
(*hashSink)(data); hashSink = std::make_unique<HashSink>(HashType::SHA256);
if (memberData->contents) { }
memberData->contents->append(data);
} void receiveContents(std::string_view data) override
assert(memberData->fileSize <= expectedSize); {
if (memberData->fileSize == expectedSize) { assert(expectedSize);
auto [hash, len] = hashSink->finish(); assert(curMember);
assert(memberData->fileSize == len); assert(hashSink);
memberData->sha256 = hash; *curMember->fileSize += data.size();
hashSink.reset(); (*hashSink)(data);
} if (curMember->contents) {
curMember->contents->append(data);
} }
}; 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
{ {