Skip to content

Commit 30531ca

Browse files
committed
Renamed function for clarity
1 parent a3e7ecc commit 30531ca

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

main.go

+2-2
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
}
161161
Systray.Update(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()

update.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ 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"})
6767
Systray.Update(path)

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)