File tree 4 files changed +13
-12
lines changed
4 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -153,15 +153,15 @@ func main() {
153
153
if src , err := os .Executable (); err != nil {
154
154
panic (err )
155
155
} else if strings .Contains (src , "-temp" ) {
156
- newPath := updater .BinPath (src )
156
+ newPath := updater .RemoveTempSuffixFromPath (src )
157
157
if err := copyExe (src , newPath ); err != nil {
158
158
log .Println ("Copy error: " , err )
159
159
panic (err )
160
160
}
161
- Systray .Update (newPath )
161
+ Systray .RestartWith (newPath )
162
162
} else {
163
163
// Otherwise copy to a path with -temp suffix
164
- if err := copyExe (src , updater .TempPath (src )); err != nil {
164
+ if err := copyExe (src , updater .AddTempSuffixToPath (src )); err != nil {
165
165
panic (err )
166
166
}
167
167
Systray .Start ()
Original file line number Diff line number Diff line change @@ -92,8 +92,8 @@ func (s *Systray) Resume() {
92
92
s .Restart ()
93
93
}
94
94
95
- // Update restarts the program with the given path
96
- func (s * Systray ) Update (path string ) {
95
+ // RestartWith restarts the program with the given path
96
+ func (s * Systray ) RestartWith (path string ) {
97
97
s .path = path
98
98
s .Restart ()
99
99
}
Original file line number Diff line number Diff line change @@ -61,8 +61,9 @@ func updateHandler(c *gin.Context) {
61
61
return
62
62
}
63
63
64
- path = updater .TempPath (path )
64
+ path = updater .AddTempSuffixToPath (path )
65
65
66
66
c .JSON (200 , gin.H {"success" : "Please wait a moment while the agent reboots itself" })
67
- Systray .Update (path )
67
+
68
+ Systray .RestartWith (path )
68
69
}
Original file line number Diff line number Diff line change @@ -68,8 +68,8 @@ var errHashMismatch = errors.New("new file hash mismatch after patch")
68
68
var errDiffURLUndefined = errors .New ("DiffURL is not defined, I cannot fetch and apply patch, reverting to full bin" )
69
69
var up = update .New ()
70
70
71
- // TempPath generates a temporary path for the executable (adding " -temp")
72
- func TempPath (path string ) string {
71
+ // AddTempSuffixToPath adds the "-temp" suffix to the path to an executable file (a ".exe" extension is replaced with " -temp.exe ")
72
+ func AddTempSuffixToPath (path string ) string {
73
73
if filepath .Ext (path ) == "exe" {
74
74
path = strings .Replace (path , ".exe" , "-temp.exe" , - 1 )
75
75
} else {
@@ -79,8 +79,8 @@ func TempPath(path string) string {
79
79
return path
80
80
}
81
81
82
- // BinPath generates the proper path for a temporary executable (removing "-temp")
83
- func BinPath (path string ) string {
82
+ // RemoveTempSuffixFromPath removes "-temp" suffix from the path to an executable file (a "-temp.exe" extension is replaced with ".exe ")
83
+ func RemoveTempSuffixFromPath (path string ) string {
84
84
return strings .Replace (path , "-temp" , "" , - 1 )
85
85
}
86
86
@@ -234,7 +234,7 @@ func (u *Updater) update() error {
234
234
return err
235
235
}
236
236
237
- path = TempPath (path )
237
+ path = AddTempSuffixToPath (path )
238
238
239
239
old , err := os .Open (path )
240
240
if err != nil {
You can’t perform that action at this time.
0 commit comments