docs
docs copied to clipboard
[Breaking change]: GnuTarEntry and PaxTarEntry no longer includes atime and ctime by default
Description
atime and ctime are problematic in tar entries - not all tar readers support them. GnuTarEntry and PaxTarEntry have been changed to not add these fields by default. The fields will still be preserved when reading, and a user may set them directly, but they will not be set on existing entries that didn't have them to start, or when converting from other entry types.
The behavior TarEntry.ModificationTime is unchanged. It is initialized to UtcNow for tar entries created with a constructor, and uses the file modification time for entries created from files.
Other minor fixes have been made to System.Formats.Tar to prioritize round-tripping of TarEntrys from read -> write without change.
cc @tmds
Version
.NET 10 Preview 5
Previous behavior
GnuTarEntry and PaxTarEntry would always add atime and ctime values.
New behavior
GnuTarEntry and PaxTarEntry only set atime and ctime if read from an entry that had them or the user explicitly set them.
Type of breaking change
- [ ] Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
- [ ] Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
- [x] Behavioral change: Existing binaries might behave differently at run time.
Reason for change
Better compatibility with other tar readers, round-tripping tar files without modification.
Recommended action
No action required for most users.
If you require these fields to be set you can do so directly with GnuTarEntry.AccessTime, GnuTarEntry.ChangeTime, or PaxTarEntry(TarEntryType entryType, string entryName, IEnumerable<KeyValuePair<string, string>> extendedAttributes)- but know that this will create a tar that is not readable by many tar clients.
Feature area
Core .NET libraries
Affected APIs
System.Formats.Tar.GnuTarEntry
System.Formats.Tar.TarReader
System.Formats.Tar.TarWriter
Thanks for the write-up, @ericstj!
We should include that PaxTarEntry also no longer includes these timestamp. This is for consistency with other tools (and GnuTarEntry).
No action required for most users.
This is the recommended action indeed: most archives have no use for these timestamps so users should not include them unless they are really needed.
For PaxTarEntry a user can set the values using the constructor that accepts extendedAttributes.
Perhaps we should also call out that the behavior TarEntry.ModificationTime is unchanged. It is initialized to UtcNow for tar entries created with a constructor, and uses the file modification time for entries created from files.
I updated the description with your feedback.
We should include that PaxTarEntry also no longer includes these timestamp. This is for consistency with other tools (and GnuTarEntry).
I see - this was removed with https://github.com/dotnet/runtime/commit/bd3ff5d26379616e9495ab75f5ee4a267e46e087#diff-391a5b4384ab4d9bd8e7ce370b44b475cc1323db9c0d9d997ef9965d38bbb67aL66-R69. Interesting, I had thought we only removed this for GnuTarEntry since that was what had the problem. I suppose if folks have issue we could always bring it back for Pax. What do you think @tmds ?
I updated the description with your feedback.
Updated text looks good.
I had thought we only removed this for GnuTarEntry since that was what had the problem. I suppose if folks have issue we could always bring it back for Pax.
If someone creates an issue for no longer including the atime and ctime for Pax archives created from filesystem, we could add it back.
It would also be helpful if we add some PaxTarEntry properties for setting/getting the extended attributes AccessTime and ChangeTime.