more logs on uncompressing archives

This commit is contained in:
rhysd 2018-01-01 16:01:42 +09:00
parent b2a4d9f099
commit 533ad72291
2 changed files with 5 additions and 0 deletions

View File

@ -25,6 +25,7 @@ func unarchiveTar(src io.Reader, url, cmd string) (io.Reader, error) {
}
_, name := filepath.Split(h.Name)
if name == cmd {
log.Println("Executable file", h.Name, "was found in tar archive")
return t, nil
}
}
@ -56,6 +57,7 @@ func UncompressCommand(src io.Reader, url, cmd string) (io.Reader, error) {
for _, file := range z.File {
_, name := filepath.Split(file.Name)
if !file.FileInfo().IsDir() && name == cmd {
log.Println("Executable file", file.Name, "was found in zip archive")
return file.Open()
}
}
@ -83,6 +85,7 @@ func UncompressCommand(src io.Reader, url, cmd string) (io.Reader, error) {
return nil, fmt.Errorf("File name '%s' does not match to command '%s' found in %s", name, cmd, url)
}
log.Println("Executable file", name, "was found in gzip file")
return r, nil
} else if strings.HasSuffix(url, ".tar.xz") {
log.Println("Uncompressing tar.xz file", url)
@ -100,6 +103,7 @@ func UncompressCommand(src io.Reader, url, cmd string) (io.Reader, error) {
if err != nil {
return nil, fmt.Errorf("Failed to uncompress xzip file downloaded from %s: %s", url, err)
}
log.Println("Uncompressed file from xzip is assumed to be an executable", cmd)
return xzip, nil
}

View File

@ -39,6 +39,7 @@ func UpdateTo(assetURL, cmdPath string) error {
// 'slug' represents 'owner/name' repository on GitHub and 'current' means the current version.
func UpdateCommand(cmdPath string, current semver.Version, slug string) (*Release, error) {
if runtime.GOOS == "windows" && !strings.HasSuffix(cmdPath, ".exe") {
// Ensure to add '.exe' to given path on Windows
cmdPath = cmdPath + ".exe"
}