• Joe Tsai's avatar
    archive/tar: require opt-in to PAX or GNU format for time features · f85dc050
    Joe Tsai authored
    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: 's avatarIan Lance Taylor <iant@golang.org>
    f85dc050
Name
Last commit
Last update
..
tar Loading commit data...
zip Loading commit data...