File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -132,30 +132,33 @@ func main() {
132132
133133 // If the executable is temporary, copy it to the full path, then restart
134134 if strings .Contains (path , "-temp" ) {
135- err := copyExe (path , updater .BinPath (path ))
135+ newPath := updater .BinPath (path )
136+ err := copyExe (path , newPath )
136137 if err != nil {
138+ log .Println ("Copy error: " , err )
137139 panic (err )
138140 }
139141
140- Systray .Restart ( )
142+ Systray .Update ( newPath )
141143 } else {
142144 // Otherwise copy to a path with -temp suffix
143145 err := copyExe (path , updater .TempPath (path ))
144146 if err != nil {
145147 panic (err )
146148 }
149+ Systray .Start ()
147150 }
148-
149- Systray .Start ()
150151}
151152
152153func copyExe (from , to string ) error {
153154 data , err := ioutil .ReadFile (from )
154155 if err != nil {
156+ log .Println ("Cannot read file: " , from )
155157 return err
156158 }
157159 err = ioutil .WriteFile (to , data , 0755 )
158160 if err != nil {
161+ log .Println ("Cannot write file: " , to )
159162 return err
160163 }
161164 return nil
Original file line number Diff line number Diff line change 55 "os/exec"
66 "strings"
77
8+ log "github.com/sirupsen/logrus"
9+
810 "github.com/kardianos/osext"
911)
1012
@@ -26,14 +28,15 @@ type Systray struct {
2628// it works by finding the executable path and launching it before quitting
2729func (s * Systray ) Restart () {
2830
29- fmt .Println (s .path )
30- fmt .Println (osext .Executable ())
3131 if s .path == "" {
32+ log .Println ("Update binary path not set" )
3233 var err error
3334 s .path , err = osext .Executable ()
3435 if err != nil {
35- fmt .Printf ("Error getting exe path using osext lib. err: %v\n " , err )
36+ log .Printf ("Error getting exe path using osext lib. err: %v\n " , err )
3637 }
38+ } else {
39+ log .Println ("Starting updated binary: " , s .path )
3740 }
3841
3942 // Trim newlines (needed on osx)
@@ -50,7 +53,7 @@ func (s *Systray) Restart() {
5053 cmd := exec .Command (s .path , args ... )
5154 err := cmd .Start ()
5255 if err != nil {
53- fmt .Printf ("Error restarting process: %v\n " , err )
56+ log .Printf ("Error restarting process: %v\n " , err )
5457 return
5558 }
5659
You can’t perform that action at this time.
0 commit comments