Skip to content

construct a new bytes.Reader per each opened file in tarfs#4

Merged
aslilac merged 3 commits intocoder:masterfrom
aslilac:concurrent-tarfs
Dec 12, 2025
Merged

construct a new bytes.Reader per each opened file in tarfs#4
aslilac merged 3 commits intocoder:masterfrom
aslilac:concurrent-tarfs

Conversation

@aslilac
Copy link
Member

@aslilac aslilac commented Dec 12, 2025

Taken from spf13#487, which for whatever reasons hasn't been merged in over eight months


Currently, every call to Open "copies" the File, but since it has pointer fields, it's not really the kind of clean independent copy that's desired here. Notably, every File shares the same bytes.Reader state.

This causes a few bugs:

  • A file which has been read to the end will be unreadable by anyone else.
  • Any file which has been Closed has had data set to nil, essentially permanently erasing that file.

My proposed solution is to introduce an internal fsEntry type, and to construct a new tarfs.File from that data on each call to Open. Continuing to share a *tar.Header field seems fine, as you shouldn't modify that during normal use.

@aslilac aslilac merged commit b0e7057 into coder:master Dec 12, 2025
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.

3 participants