From 905eb9f6709da4d49a1467531b58b8c8901097b5 Mon Sep 17 00:00:00 2001 From: rhysd Date: Thu, 19 Dec 2019 16:26:45 +0900 Subject: [PATCH] fix .tgz file is not handled on UncompressCommand --- selfupdate/testdata/foo.tgz | Bin 0 -> 241 bytes selfupdate/uncompress.go | 4 ++-- selfupdate/uncompress_test.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 selfupdate/testdata/foo.tgz diff --git a/selfupdate/testdata/foo.tgz b/selfupdate/testdata/foo.tgz new file mode 100644 index 0000000000000000000000000000000000000000..b2f972f260325eeb7b917cdf01ae08c0db471f3d GIT binary patch literal 241 zcmVe;E_7jX0PWUI3c@fD1>mebMQ&gwe?3n`LkmKsiHmxA zlSXtQDisnJzK@pK1ZLndA$}aUtTK^w#*}JH6;hX4Fj7*ICL@htf`mk-tjEk$(d@|I;v6eFUz0|5?iUTP5-S rYvG>%&RuHtShfF4{!$U{e*gdg00000000000D#r5qzk={04M+e3*~VK literal 0 HcmV?d00001 diff --git a/selfupdate/uncompress.go b/selfupdate/uncompress.go index 8f461a6..0449ec9 100644 --- a/selfupdate/uncompress.go +++ b/selfupdate/uncompress.go @@ -59,7 +59,7 @@ func unarchiveTar(src io.Reader, url, cmd string) (io.Reader, error) { // UncompressCommand uncompresses the given source. Archive and compression format is // automatically detected from 'url' parameter, which represents the URL of asset. // This returns a reader for the uncompressed command given by 'cmd'. '.zip', -// '.tar.gz', '.tar.xz', '.gz' and '.xz' are supported. +// '.tar.gz', '.tar.xz', '.tgz', '.gz' and '.xz' are supported. func UncompressCommand(src io.Reader, url, cmd string) (io.Reader, error) { if strings.HasSuffix(url, ".zip") { log.Println("Uncompressing zip file", url) @@ -86,7 +86,7 @@ func UncompressCommand(src io.Reader, url, cmd string) (io.Reader, error) { } return nil, fmt.Errorf("File '%s' for the command is not found in %s", cmd, url) - } else if strings.HasSuffix(url, ".tar.gz") { + } else if strings.HasSuffix(url, ".tar.gz") || strings.HasSuffix(url, ".tgz") { log.Println("Uncompressing tar.gz file", url) gz, err := gzip.NewReader(src) diff --git a/selfupdate/uncompress_test.go b/selfupdate/uncompress_test.go index 5281b1f..12bb812 100644 --- a/selfupdate/uncompress_test.go +++ b/selfupdate/uncompress_test.go @@ -44,6 +44,7 @@ func TestUncompress(t *testing.T) { "testdata/single-file.gz", "testdata/single-file.gzip", "testdata/foo.tar.gz", + "testdata/foo.tgz", "testdata/foo.tar.xz", "testdata/single-file.xz", } {