Description
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 TarEntry
s 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.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
Metadata
Metadata
Type
Projects
Status
Activity
tmds commentedon May 29, 2025
Thanks for the write-up, @ericstj!
We should include that
PaxTarEntry
also no longer includes these timestamp. This is for consistency with other tools (andGnuTarEntry
).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 acceptsextendedAttributes
.tmds commentedon May 29, 2025
Perhaps we should also call out that the behavior
TarEntry.ModificationTime
is unchanged. It is initialized toUtcNow
for tar entries created with a constructor, and uses the file modification time for entries created from files.[-][Breaking change]: GnuTarEntry no longer includes atime and ctime by default[/-][+][Breaking change]: GnuTarEntry and PaxTarEntry no longer includes atime and ctime by default[/+]ericstj commentedon May 29, 2025
I updated the description with your feedback.
I see - this was removed with dotnet/runtime@bd3ff5d#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 ?tmds commentedon Jun 4, 2025
Updated text looks good.
If someone creates an issue for no longer including the
atime
andctime
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 attributesAccessTime
andChangeTime
.