Skip to content

Allow update for dev #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 14 additions & 24 deletions updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
"time"

log "github.com/Sirupsen/logrus"
"github.com/inconshreveable/go-update"
"github.com/kr/binarydist"

"github.com/inconshreveable/go-update"
"github.com/kardianos/osext"
)

Expand Down Expand Up @@ -90,22 +89,20 @@ type Updater struct {
// BackgroundRun starts the update check and apply cycle.
func (u *Updater) BackgroundRun() error {
os.MkdirAll(u.getExecRelativeDir(u.Dir), 0777)
if u.wantUpdate() {
if err := up.CanUpdate(); err != nil {
log.Println(err)
return err
}
//self, err := osext.Executable()
//if err != nil {
// fail update, couldn't figure out path to self
//return
//}
// TODO(bgentry): logger isn't on Windows. Replace w/ proper error reports.
if err := u.update(); err != nil {
return err
}
if err := up.CanUpdate(); err != nil {
log.Println(err)
return err
}
//self, err := osext.Executable()
//if err != nil {
// fail update, couldn't figure out path to self
//return
//}
// TODO(bgentry): logger isn't on Windows. Replace w/ proper error reports.
if err := u.update(); err != nil {
return err
}
return errors.New("Won't update because it's a development daemon. Change the version in main.go")
return nil
}

func fetch(url string) (io.ReadCloser, error) {
Expand Down Expand Up @@ -255,10 +252,3 @@ func (u *Updater) update() error {

return nil
}

func (u *Updater) wantUpdate() bool {
if strings.Contains(u.CurrentVersion, "dev") {
return false
}
return true
}