File tree 2 files changed +14
-8
lines changed
2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -132,30 +132,33 @@ func main() {
132
132
133
133
// If the executable is temporary, copy it to the full path, then restart
134
134
if strings .Contains (path , "-temp" ) {
135
- err := copyExe (path , updater .BinPath (path ))
135
+ newPath := updater .BinPath (path )
136
+ err := copyExe (path , newPath )
136
137
if err != nil {
138
+ log .Println ("Copy error: " , err )
137
139
panic (err )
138
140
}
139
141
140
- Systray .Restart ( )
142
+ Systray .Update ( newPath )
141
143
} else {
142
144
// Otherwise copy to a path with -temp suffix
143
145
err := copyExe (path , updater .TempPath (path ))
144
146
if err != nil {
145
147
panic (err )
146
148
}
149
+ Systray .Start ()
147
150
}
148
-
149
- Systray .Start ()
150
151
}
151
152
152
153
func copyExe (from , to string ) error {
153
154
data , err := ioutil .ReadFile (from )
154
155
if err != nil {
156
+ log .Println ("Cannot read file: " , from )
155
157
return err
156
158
}
157
159
err = ioutil .WriteFile (to , data , 0755 )
158
160
if err != nil {
161
+ log .Println ("Cannot write file: " , to )
159
162
return err
160
163
}
161
164
return nil
Original file line number Diff line number Diff line change 5
5
"os/exec"
6
6
"strings"
7
7
8
+ log "github.com/sirupsen/logrus"
9
+
8
10
"github.com/kardianos/osext"
9
11
)
10
12
@@ -26,14 +28,15 @@ type Systray struct {
26
28
// it works by finding the executable path and launching it before quitting
27
29
func (s * Systray ) Restart () {
28
30
29
- fmt .Println (s .path )
30
- fmt .Println (osext .Executable ())
31
31
if s .path == "" {
32
+ log .Println ("Update binary path not set" )
32
33
var err error
33
34
s .path , err = osext .Executable ()
34
35
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 )
36
37
}
38
+ } else {
39
+ log .Println ("Starting updated binary: " , s .path )
37
40
}
38
41
39
42
// Trim newlines (needed on osx)
@@ -50,7 +53,7 @@ func (s *Systray) Restart() {
50
53
cmd := exec .Command (s .path , args ... )
51
54
err := cmd .Start ()
52
55
if err != nil {
53
- fmt .Printf ("Error restarting process: %v\n " , err )
56
+ log .Printf ("Error restarting process: %v\n " , err )
54
57
return
55
58
}
56
59
You can’t perform that action at this time.
0 commit comments