parent
e212b64823
commit
174befe729
|
@ -9,6 +9,8 @@ import (
|
|||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"bitbucket.org/kardianos/osext"
|
||||
)
|
||||
|
||||
type Release struct {
|
||||
|
@ -38,7 +40,12 @@ func init() {
|
|||
func UpgradeTo(rel Release, archExtra string) error {
|
||||
select {
|
||||
case <-upgradeUnlocked:
|
||||
err := upgradeTo(rel, archExtra)
|
||||
path, err := osext.Executable()
|
||||
if err != nil {
|
||||
upgradeUnlocked <- true
|
||||
return err
|
||||
}
|
||||
err = upgradeTo(path, rel, archExtra)
|
||||
// If we've failed to upgrade, unlock so that another attempt could be made
|
||||
if err != nil {
|
||||
upgradeUnlocked <- true
|
||||
|
|
|
@ -19,16 +19,10 @@ import (
|
|||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"bitbucket.org/kardianos/osext"
|
||||
)
|
||||
|
||||
// Upgrade to the given release, saving the previous binary with a ".old" extension.
|
||||
func upgradeTo(rel Release, archExtra string) error {
|
||||
path, err := osext.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
func upgradeTo(path string, rel Release, archExtra string) error {
|
||||
osName := runtime.GOOS
|
||||
if osName == "darwin" {
|
||||
// We call the darwin release bundles macosx because that makes more
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
package upgrade
|
||||
|
||||
func upgradeTo(rel Release, extra string) error {
|
||||
func upgradeTo(path string, rel Release, extra string) error {
|
||||
return ErrUpgradeUnsupported
|
||||
}
|
||||
|
||||
|
|
|
@ -19,16 +19,10 @@ import (
|
|||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"bitbucket.org/kardianos/osext"
|
||||
)
|
||||
|
||||
// Upgrade to the given release, saving the previous binary with a ".old" extension.
|
||||
func upgradeTo(rel Release, archExtra string) error {
|
||||
path, err := osext.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
func upgradeTo(path string, rel Release, archExtra string) error {
|
||||
expectedRelease := fmt.Sprintf("syncthing-%s-%s%s-%s.", runtime.GOOS, runtime.GOARCH, archExtra, rel.Tag)
|
||||
if debug {
|
||||
l.Debugf("expected release asset %q", expectedRelease)
|
||||
|
|
Loading…
Reference in New Issue