diff --git a/main.go b/main.go index d3cb56b8c..231f5dc48 100755 --- a/main.go +++ b/main.go @@ -132,30 +132,33 @@ func main() { // If the executable is temporary, copy it to the full path, then restart if strings.Contains(path, "-temp") { - err := copyExe(path, updater.BinPath(path)) + newPath := updater.BinPath(path) + err := copyExe(path, newPath) if err != nil { + log.Println("Copy error: ", err) panic(err) } - Systray.Restart() + Systray.Update(newPath) } else { // Otherwise copy to a path with -temp suffix err := copyExe(path, updater.TempPath(path)) if err != nil { panic(err) } + Systray.Start() } - - Systray.Start() } func copyExe(from, to string) error { data, err := ioutil.ReadFile(from) if err != nil { + log.Println("Cannot read file: ", from) return err } err = ioutil.WriteFile(to, data, 0755) if err != nil { + log.Println("Cannot write file: ", to) return err } return nil diff --git a/systray/systray.go b/systray/systray.go index 8ef805789..7b3f9f5db 100644 --- a/systray/systray.go +++ b/systray/systray.go @@ -5,6 +5,8 @@ import ( "os/exec" "strings" + log "github.com/sirupsen/logrus" + "github.com/kardianos/osext" ) @@ -26,14 +28,15 @@ type Systray struct { // it works by finding the executable path and launching it before quitting func (s *Systray) Restart() { - fmt.Println(s.path) - fmt.Println(osext.Executable()) if s.path == "" { + log.Println("Update binary path not set") var err error s.path, err = osext.Executable() if err != nil { - fmt.Printf("Error getting exe path using osext lib. err: %v\n", err) + log.Printf("Error getting exe path using osext lib. err: %v\n", err) } + } else { + log.Println("Starting updated binary: ", s.path) } // Trim newlines (needed on osx) @@ -50,7 +53,7 @@ func (s *Systray) Restart() { cmd := exec.Command(s.path, args...) err := cmd.Start() if err != nil { - fmt.Printf("Error restarting process: %v\n", err) + log.Printf("Error restarting process: %v\n", err) return }