]> Cypherpunks repositories - gostls13.git/commit
archive/tar: require opt-in to PAX or GNU format for time features
authorJoe Tsai <joetsai@digital-static.net>
Fri, 25 Aug 2017 23:48:46 +0000 (16:48 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Wed, 30 Aug 2017 18:00:59 +0000 (18:00 +0000)
commitf85dc050bad21c60c7fc0cf0ee45ab99e2bf93d2
tree6b102f3d342104bb6e8e84698bbbff20818758ac
parent0592a1a3de99fd5e862092332063daeb3158363e
archive/tar: require opt-in to PAX or GNU format for time features

Nearly every Header obtained from FileInfoHeader via the FS has
timestamps with sub-second resolution and the AccessTime
and ChangeTime fields populated. This forces the PAX format
to almost always be used, which has the following problems:
* PAX is still not as widely supported compared to USTAR
* The PAX headers will occupy at minimum 1KiB for every entry

The old behavior of tar Writer had no support for sub-second resolution
nor any support for AccessTime or ChangeTime, so had neither problem.
Instead the Writer would just truncate sub-second information and
ignore the AccessTime and ChangeTime fields.

In this CL, we preserve the behavior such that the *default* behavior
would output a USTAR header for most cases by truncating sub-second
time measurements and ignoring AccessTime and ChangeTime.
To use either of the features, users will need to explicitly specify
that the format is PAX or GNU.

The exact policy chosen is this:
* USTAR and GNU may still be chosen even if sub-second measurements
are present; they simply truncate the timestamp to the nearest second.
As before, PAX uses sub-second resolutions.
* If the Format is unspecified, then WriteHeader ignores AccessTime
and ChangeTime when using the USTAR format.

This ensures that USTAR may still be chosen for a vast majority of
file entries obtained through FileInfoHeader.

Updates #11171
Updates #17876

Change-Id: Icc5274d4245922924498fd79b8d3ae94d5717271
Reviewed-on: https://go-review.googlesource.com/59230
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/archive/tar/common.go
src/archive/tar/format.go
src/archive/tar/tar_test.go