Skip to content

feat(pkg/nar): introduce NAR writer#33

Merged
flokli merged 8 commits into
nix-community:masterfrom
flokli:nar-writer
Mar 19, 2022
Merged

feat(pkg/nar): introduce NAR writer#33
flokli merged 8 commits into
nix-community:masterfrom
flokli:nar-writer

Conversation

@flokli

@flokli flokli commented Mar 19, 2022

Copy link
Copy Markdown
Member

This introduces the writer component for pkg/nar, with a similar interface to archive/tar.

It also increases test coverage for the NAR reader, thanks to some of the fixtures created for the NAR writer tests.

There's probably some more places where we could have more test coverage, mostly premature closing of the NAR readers and writers, but this can be done as a follow-up.

flokli added 6 commits March 19, 2022 17:09
We need to ensure the whole node name matches the regex, not only a part
of it.
Just return directly what we want to return.
BytesWriter implements writing bytes fields.
It'll return a io.WriteCloser that can be written to.
On Write(), it'll verify we don't write more than was initially specified.
On Close(), it'll verify exactly the previously specified number of bytes were written, then write any necessary padding
When closing multiple times, wire.BytesWriter kept writing padding.

This will keep track of that fact, and not write padding in case it was
already successfully written. Behaviour on a second close after a failed
first close still is undefined.
Make use of the gen*Nar() functions introduced by the NAR writer tests,
and drive the NAR reader with it, too.

@zimbatm zimbatm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the goroutine business, which I am still unsure about, the rest looks good.

Comment thread pkg/nar/types.go
@flokli flokli merged commit 55d9dd4 into nix-community:master Mar 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants