Skip to content

Commit 3d7780f

Browse files
authored
Function rename to increase readability (#766)
* Renamed function for clarity * Renamed method for clarity
1 parent a3e7ecc commit 3d7780f

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ func main() {
153153
if src, err := os.Executable(); err != nil {
154154
panic(err)
155155
} else if strings.Contains(src, "-temp") {
156-
newPath := updater.BinPath(src)
156+
newPath := updater.RemoveTempSuffixFromPath(src)
157157
if err := copyExe(src, newPath); err != nil {
158158
log.Println("Copy error: ", err)
159159
panic(err)
160160
}
161-
Systray.Update(newPath)
161+
Systray.RestartWith(newPath)
162162
} else {
163163
// 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 {
165165
panic(err)
166166
}
167167
Systray.Start()

systray/systray.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ func (s *Systray) Resume() {
9292
s.Restart()
9393
}
9494

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) {
9797
s.path = path
9898
s.Restart()
9999
}

update.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ func updateHandler(c *gin.Context) {
6161
return
6262
}
6363

64-
path = updater.TempPath(path)
64+
path = updater.AddTempSuffixToPath(path)
6565

6666
c.JSON(200, gin.H{"success": "Please wait a moment while the agent reboots itself"})
67-
Systray.Update(path)
67+
68+
Systray.RestartWith(path)
6869
}

updater/updater.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ var errHashMismatch = errors.New("new file hash mismatch after patch")
6868
var errDiffURLUndefined = errors.New("DiffURL is not defined, I cannot fetch and apply patch, reverting to full bin")
6969
var up = update.New()
7070

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 {
7373
if filepath.Ext(path) == "exe" {
7474
path = strings.Replace(path, ".exe", "-temp.exe", -1)
7575
} else {
@@ -79,8 +79,8 @@ func TempPath(path string) string {
7979
return path
8080
}
8181

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 {
8484
return strings.Replace(path, "-temp", "", -1)
8585
}
8686

@@ -234,7 +234,7 @@ func (u *Updater) update() error {
234234
return err
235235
}
236236

237-
path = TempPath(path)
237+
path = AddTempSuffixToPath(path)
238238

239239
old, err := os.Open(path)
240240
if err != nil {

0 commit comments

Comments
 (0)