diff --git a/lix/libutil/archive.cc b/lix/libutil/archive.cc index 80e0c9781..6d63abd5a 100644 --- a/lix/libutil/archive.cc +++ b/lix/libutil/archive.cc @@ -708,6 +708,7 @@ struct AsyncParser file->receiveContents({buf.data(), n}); left -= n; } + file->close(); } else if (auto sl = std::get_if(&*i)) { target.createSymlink(name, sl->target); } else if (auto d = std::get_if(&*i)) { diff --git a/tests/unit/libutil/archive.cc b/tests/unit/libutil/archive.cc index 51189d092..509c1d23d 100644 --- a/tests/unit/libutil/archive.cc +++ b/tests/unit/libutil/archive.cc @@ -248,6 +248,7 @@ namespace parseAsync { { bool executable; uint64_t size; + bool closed; std::string contents; operator nar::Entry() const { @@ -292,7 +293,10 @@ namespace parseAsync { file.contents += data; } - void close() override {} + void close() override + { + file.closed = true; + } }; explicit ReconstructVisitor(std::map & parent) : parent(parent) {} @@ -306,7 +310,8 @@ namespace parseAsync { box_ptr createRegularFile(const std::string & name, uint64_t size, bool executable) override { - auto & file = std::get(parent.emplace(name, File{executable, size}).first->second); + auto & file = + std::get(parent.emplace(name, File{executable, size, false}).first->second); return make_box_ptr(file); } @@ -331,6 +336,13 @@ TEST_P(NarTest, parseAsync) auto entries = entriesFn()(); parseDump(rv, source).wait(ws).value(); + + for (auto & [i, val] : contents) { + if (auto f = std::get_if(&val)) { + ASSERT_TRUE(f->closed); + } + } + auto parsed = parseAsync::Directory::toNar(contents.at("")); while (true) { auto e = entries.next();