From 04ab271e9a8970a0747fda7f0cb582420c46f4cb Mon Sep 17 00:00:00 2001 From: Leo Pang <34628052+allthatjazzleo@users.noreply.github.com> Date: Sun, 11 Apr 2021 00:20:33 +0800 Subject: [PATCH] cosmovisor: move binrary to UpgradeBin from directory (fix #8494) (#8497) --- cosmovisor/upgrade.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cosmovisor/upgrade.go b/cosmovisor/upgrade.go index 3057597f7d..7e8091d611 100644 --- a/cosmovisor/upgrade.go +++ b/cosmovisor/upgrade.go @@ -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) }