Please sign in to comment.
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 <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com> Reviewed-by: Ian Lance Taylor <firstname.lastname@example.org>
- Loading branch information...
Showing with 105 additions and 14 deletions.