Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aslilac
Copy link

@aslilac aslilac commented Apr 3, 2025

Closes #486

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.

@CLAassistant
Copy link

CLAassistant commented Apr 3, 2025

CLA assistant check
All committers have signed the CLA.

@aslilac aslilac changed the title construct a new bytes.Reader per each opened file construct a new bytes.Reader per each opened file in tarfs Apr 3, 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.

tarfs.FS uses shared file position for each file handler
2 participants