add more logs
This commit is contained in:
parent
fd8fc6616a
commit
0cce7553af
|
@ -5,7 +5,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEnableDisableLog(t *testing.T) {
|
func TestEnableDisableLog(t *testing.T) {
|
||||||
defer EnableLog()
|
defer DisableLog()
|
||||||
|
|
||||||
EnableLog()
|
EnableLog()
|
||||||
if !logEnabled {
|
if !logEnabled {
|
||||||
|
|
|
@ -14,6 +14,8 @@ import (
|
||||||
|
|
||||||
func uncompress(src io.Reader, url, cmd string) (io.Reader, error) {
|
func uncompress(src io.Reader, url, cmd string) (io.Reader, error) {
|
||||||
if strings.HasSuffix(url, ".zip") {
|
if strings.HasSuffix(url, ".zip") {
|
||||||
|
log.Println("Uncompressing zip file", url)
|
||||||
|
|
||||||
// Zip format requires its file size for uncompressing.
|
// Zip format requires its file size for uncompressing.
|
||||||
// So we need to read the HTTP response into a buffer at first.
|
// So we need to read the HTTP response into a buffer at first.
|
||||||
buf, err := ioutil.ReadAll(src)
|
buf, err := ioutil.ReadAll(src)
|
||||||
|
@ -36,6 +38,8 @@ func uncompress(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)
|
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") {
|
||||||
|
log.Println("Uncompressing tar.gz file", url)
|
||||||
|
|
||||||
gz, err := gzip.NewReader(src)
|
gz, err := gzip.NewReader(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Failed to uncompress .tar.gz file: %s", err)
|
return nil, fmt.Errorf("Failed to uncompress .tar.gz file: %s", err)
|
||||||
|
@ -58,6 +62,8 @@ func uncompress(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)
|
return nil, fmt.Errorf("File '%s' for the command is not found in %s", cmd, url)
|
||||||
} else if strings.HasSuffix(url, ".gzip") || strings.HasSuffix(url, ".gz") {
|
} else if strings.HasSuffix(url, ".gzip") || strings.HasSuffix(url, ".gz") {
|
||||||
|
log.Println("Uncompressing gzip file", url)
|
||||||
|
|
||||||
r, err := gzip.NewReader(src)
|
r, err := gzip.NewReader(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Failed to uncompress gzip file downloaded from %s: %s", url, err)
|
return nil, fmt.Errorf("Failed to uncompress gzip file downloaded from %s: %s", url, err)
|
||||||
|
@ -71,5 +77,6 @@ func uncompress(src io.Reader, url, cmd string) (io.Reader, error) {
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("Uncompression is not needed", url)
|
||||||
return src, nil
|
return src, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ func UpdateTo(assetURL, cmdPath string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("Will update", cmdPath, "to the latest downloaded from", assetURL)
|
||||||
return update.Apply(asset, update.Options{
|
return update.Apply(asset, update.Options{
|
||||||
TargetPath: cmdPath,
|
TargetPath: cmdPath,
|
||||||
})
|
})
|
||||||
|
@ -40,11 +41,14 @@ func UpdateCommand(cmdPath string, current semver.Version, slug string) (*Releas
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Println("No release detected. Current version is considered up-to-date")
|
||||||
return &Release{Version: current}, nil
|
return &Release{Version: current}, nil
|
||||||
}
|
}
|
||||||
if current.Equals(rel.Version) {
|
if current.Equals(rel.Version) {
|
||||||
|
log.Println("Current version", current, "is the latest. Update is not needed")
|
||||||
return rel, nil
|
return rel, nil
|
||||||
}
|
}
|
||||||
|
log.Println("Will update", cmdPath, "to the latest version", rel.Version)
|
||||||
if err := UpdateTo(rel.AssetURL, cmdPath); err != nil {
|
if err := UpdateTo(rel.AssetURL, cmdPath); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue