Skip to content

Fix temp binary not starting correclty #583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 5, 2021
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,30 +132,33 @@ func main() {

// If the executable is temporary, copy it to the full path, then restart
if strings.Contains(path, "-temp") {
err := copyExe(path, updater.BinPath(path))
newPath := updater.BinPath(path)
err := copyExe(path, newPath)
if err != nil {
log.Println("Copy error: ", err)
panic(err)
}

Systray.Restart()
Systray.Update(newPath)
Comment on lines -140 to +142
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restart() does not pass the path of the binary to start
Update() sets this path and then calls Restart()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the implementation of Update and Restart

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea!

} else {
// Otherwise copy to a path with -temp suffix
err := copyExe(path, updater.TempPath(path))
if err != nil {
panic(err)
}
Systray.Start()
}

Systray.Start()
}

func copyExe(from, to string) error {
data, err := ioutil.ReadFile(from)
if err != nil {
log.Println("Cannot read file: ", from)
return err
}
err = ioutil.WriteFile(to, data, 0755)
if err != nil {
log.Println("Cannot write file: ", to)
return err
}
return nil
Expand Down