tar_time: treat time from tar archives special

Since the field in a tar header for each file only preserves seconds
precision, not nanosecond precision, let's handle it special. This will
allow for more custom case handling in Check()

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-07-22 15:53:05 -04:00 committed by Stephen Chung
parent decc72b335
commit bc6f3bf902
2 changed files with 18 additions and 0 deletions

6
tar.go
View file

@ -102,6 +102,9 @@ func (ts *tarStream) readHeaders() {
// now collect keywords on the file
for _, keyword := range ts.keywords {
if keyword == "time" {
keyword = "tar_time"
}
if keyFunc, ok := KeywordFuncs[keyword]; ok {
// We can't extract directories on to disk, so "size" keyword
// is irrelevant for now
@ -140,6 +143,9 @@ func (ts *tarStream) readHeaders() {
Type: SpecialType,
}
for _, setKW := range SetKeywords {
if setKW == "time" {
setKW = "tar_time"
}
if keyFunc, ok := KeywordFuncs[setKW]; ok {
val, err := keyFunc(hdr.Name, hdr.FileInfo(), tmpFile)
if err != nil {