cosmovisor: move binrary to UpgradeBin from directory (fix #8494) (#8497)

This commit is contained in:
Leo Pang 2021-04-11 00:20:33 +08:00 committed by GitHub
parent 7a3a156b4f
commit 04ab271e9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import (
"strings"
"github.com/hashicorp/go-getter"
"github.com/otiai10/copy"
)
// DoUpgrade will be called after the log message has been parsed and the process has terminated.
@ -62,10 +63,19 @@ func DownloadBinary(cfg *Config, info *UpgradeInfo) error {
if err != nil {
dirPath := cfg.UpgradeDir(info.Name)
err = getter.Get(dirPath, url)
if err != nil {
return err
}
err = EnsureBinary(binPath)
// copy binary to binPath from dirPath if zipped directory don't contain bin directory to wrap the binary
if err != nil {
err = copy.Copy(filepath.Join(dirPath, cfg.Name), binPath)
if err != nil {
return err
}
}
}
if err != nil {
return err
}
// if it is successful, let's ensure the binary is executable
return MarkExecutable(binPath)
}