mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 01:45:44 +03:00
Update go-getter to pick up file accesstime fix
This commit is contained in:
committed by
Alex Dadgar
parent
f595e9fbfb
commit
0559dfb9ee
24
vendor/github.com/hashicorp/go-getter/decompress_tar.go
generated
vendored
24
vendor/github.com/hashicorp/go-getter/decompress_tar.go
generated
vendored
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
|
||||
// untar is a shared helper for untarring an archive. The reader should provide
|
||||
@@ -14,6 +15,7 @@ func untar(input io.Reader, dst, src string, dir bool) error {
|
||||
tarR := tar.NewReader(input)
|
||||
done := false
|
||||
dirHdrs := []*tar.Header{}
|
||||
now := time.Now()
|
||||
for {
|
||||
hdr, err := tarR.Next()
|
||||
if err == io.EOF {
|
||||
@@ -95,8 +97,16 @@ func untar(input io.Reader, dst, src string, dir bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Set the access and modification time
|
||||
if err := os.Chtimes(path, hdr.AccessTime, hdr.ModTime); err != nil {
|
||||
// Set the access and modification time if valid, otherwise default to current time
|
||||
aTime := now
|
||||
mTime := now
|
||||
if hdr.AccessTime.Unix() > 0 {
|
||||
aTime = hdr.AccessTime
|
||||
}
|
||||
if hdr.ModTime.Unix() > 0 {
|
||||
mTime = hdr.ModTime
|
||||
}
|
||||
if err := os.Chtimes(path, aTime, mTime); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -109,7 +119,15 @@ func untar(input io.Reader, dst, src string, dir bool) error {
|
||||
return err
|
||||
}
|
||||
// Set the mtime/atime attributes since they would have been changed during extraction
|
||||
if err := os.Chtimes(path, dirHdr.AccessTime, dirHdr.ModTime); err != nil {
|
||||
aTime := now
|
||||
mTime := now
|
||||
if dirHdr.AccessTime.Unix() > 0 {
|
||||
aTime = dirHdr.AccessTime
|
||||
}
|
||||
if dirHdr.ModTime.Unix() > 0 {
|
||||
mTime = dirHdr.ModTime
|
||||
}
|
||||
if err := os.Chtimes(path, aTime, mTime); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
21
vendor/github.com/hashicorp/go-getter/decompress_testing.go
generated
vendored
21
vendor/github.com/hashicorp/go-getter/decompress_testing.go
generated
vendored
@@ -72,9 +72,13 @@ func TestDecompressor(t testing.T, d Decompressor, cases []TestDecompressCase) {
|
||||
|
||||
if tc.Mtime != nil {
|
||||
actual := fi.ModTime()
|
||||
expected := *tc.Mtime
|
||||
if actual != expected {
|
||||
t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), dst, actual.String())
|
||||
if tc.Mtime.Unix() > 0 {
|
||||
expected := *tc.Mtime
|
||||
if actual != expected {
|
||||
t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), dst, actual.String())
|
||||
}
|
||||
} else if actual.Unix() <= 0 {
|
||||
t.Fatalf("err %s: expected mtime to be > 0, got '%s'", actual.String())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,10 +107,15 @@ func TestDecompressor(t testing.T, d Decompressor, cases []TestDecompressCase) {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
actual := fi.ModTime()
|
||||
expected := *tc.Mtime
|
||||
if actual != expected {
|
||||
t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), path, actual.String())
|
||||
if tc.Mtime.Unix() > 0 {
|
||||
expected := *tc.Mtime
|
||||
if actual != expected {
|
||||
t.Fatalf("err %s: expected mtime '%s' for %s, got '%s'", tc.Input, expected.String(), path, actual.String())
|
||||
}
|
||||
} else if actual.Unix() < 0 {
|
||||
t.Fatalf("err %s: expected mtime to be > 0, got '%s'", actual.String())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
2407
vendor/vendor.json
vendored
2407
vendor/vendor.json
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user