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

[Draft][release/7.0-rc1] Backport tar bug fixes and improvements #74414

Closed
wants to merge 8 commits into from

Conversation

carlossanlop
Copy link
Member

Customer Impact

The tar APIs are new to 7.0. These changes make sure we ship the new APIs with great performance and fixes for important bugs we found in the last weeks.

Testing

Added a large number of tests to cover all the bugs fixed in these commits.

Risk

System.Formats.Tar is a new namespace, so the risk is low.

Pending: #74412

stephentoub and others added 7 commits August 23, 2022 03:33
* Avoid unnecessary byte[] allocations

* Remove unnecessary use of FileStreamOptions

* Clean up Dispose{Async} implementations

* Clean up unnecessary consts

Not a perf thing, just readability.

* Remove MemoryStream/Encoding.UTF8.GetBytes allocations, unnecessary async variants, and overhaul GenerateExtendedAttributesDataStream

* Avoid string allocations in ReadMagicAttribute

* Avoid allocation in WriteAsOctal

* Improve handling of octal

* Avoid allocation for version string

* Removing boxing and char string allocation in GenerateExtendedAttributeName

* Fix a couple unnecessary dictionary lookups

* Replace Enum.HasFlag usage

* Remove allocations from Write{Posix}Name

* Replace ArrayPool use with string.Create

* Replace more superfluous ArrayPool usage

* Remove ArrayPool use from System.IO.Compression.ZipFile

* Fix inverted condition

* Use generic math to parse octal

* Remove allocations from StringReader and string.Split

* Remove magic string allocation for Ustar when not V7

* Remove file name and directory name allocation in GenerateExtendedAttributeName
* Fix a few Tar issues post perf improvements

* Update src/libraries/System.Formats.Tar/src/System/Formats/Tar/TarHeader.Write.cs
…74376)

* Skip directory symlink recursion on TarFile archive creation

* Add symlink verification

* Address suggestions by danmoseley

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
@ghost
Copy link

ghost commented Aug 23, 2022

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Customer Impact

The tar APIs are new to 7.0. These changes make sure we ship the new APIs with great performance and fixes for important bugs we found in the last weeks.

Testing

Added a large number of tests to cover all the bugs fixed in these commits.

Risk

System.Formats.Tar is a new namespace, so the risk is low.

Pending: #74412

Author: carlossanlop
Assignees: -
Labels:

area-System.IO

Milestone: -

…r case bugs (dotnet#74412)

* Remove unused _readFirstEntry. Remnant from before we created PaxGlobalExtendedAttributesEntry.

* Set the position of the freshly copied data stream to 0, so the first user access of the DataStream property gives them a stream ready to read from the beginning.

* Process a PAX actual entry's data block only after the extended attributes are analyzed, in case the size is found as an extended attribute and needs to be overriden.

* Add tests to verify the entries of the new external tar assets can be read. Verify their DataStream if available.

* Add copyData argument to recent alignment padding tests.

* Throw an exception sooner and with a clearer message when a data section is unexpected for the entry type.

* Allow trailing nulls and spaces in octal fields.
Co-authored-by: @am11 Adeel Mujahid <3840695+am11@users.noreply.github.com>

* Throw a clearer exception if the unsupported sparse file entry type is encountered. These entries have additional data that indicates the locations of sparse bytes, which cannot be read with just the size field. So to avoid accidentally offseting the reader, we throw.

* Tests.

* Rename to TrimLeadingNullsAndSpaces

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
@danmoseley
Copy link
Member

@carlossanlop I suggest to pull out changes to Zip -- ZipFile.Create.cs
Those are totally opportunistic. We are only porting all the tar changes together here to avoid confusing code divergence. There is no such reason to touch Zip. I see the changes in the common code will only be used by Tar, also, so that's fine.

@danmoseley
Copy link
Member

also it seems from offline discussion we likely want to put in release/7.0. I suggest closing this and creating a new PR against that once your changes go into main today.

@danmoseley
Copy link
Member

Oh, it already did. If you like, you could keep this open since you already kicked it off again, so we keep the option open to take it into rc1, but put up a new PR for rc2 now.

@danmoseley danmoseley added the NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons) label Aug 23, 2022
@carlossanlop
Copy link
Member Author

carlossanlop commented Aug 23, 2022

Changes went into main already and I cherry-picked them here. I only need to remove the Compression changes. Should I still target 7.0?

@carlossanlop
Copy link
Member Author

carlossanlop commented Aug 23, 2022

As discussed, abandoning this PR in favor of one for release/7.0 #74449

@carlossanlop carlossanlop deleted the tarBackport branch August 23, 2022 19:11
@ghost ghost locked as resolved and limited conversation to collaborators Sep 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Formats.Tar NO-MERGE The PR is not ready for merge yet (see discussion for detailed reasons)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants