afero icon indicating copy to clipboard operation
afero copied to clipboard

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

Open aslilac opened this issue 7 months ago • 4 comments
trafficstars

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.

aslilac avatar Apr 03 '25 16:04 aslilac