-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f2aad39
fix strange temp binary file behavior:
umbynos 1c168a8
add some useful logs
umbynos 0910bcb
Systray.Start() was called even if the program have to restart
umbynos cbd9df5
added useful prints
umbynos 53ac251
replace fmt with a proper logger
umbynos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ import ( | |
"os/exec" | ||
"strings" | ||
|
||
log "github.com/sirupsen/logrus" | ||
|
||
"github.com/kardianos/osext" | ||
) | ||
|
||
|
@@ -26,14 +28,15 @@ type Systray struct { | |
// it works by finding the executable path and launching it before quitting | ||
func (s *Systray) Restart() { | ||
|
||
fmt.Println(s.path) | ||
fmt.Println(osext.Executable()) | ||
if s.path == "" { | ||
log.Println("Update binary path not set") | ||
var err error | ||
s.path, err = osext.Executable() | ||
if err != nil { | ||
fmt.Printf("Error getting exe path using osext lib. err: %v\n", err) | ||
log.Printf("Error getting exe path using osext lib. err: %v\n", err) | ||
Comment on lines
-35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kill 'em all! |
||
} | ||
} else { | ||
log.Println("Starting updated binary: ", s.path) | ||
} | ||
|
||
// Trim newlines (needed on osx) | ||
|
@@ -50,7 +53,7 @@ func (s *Systray) Restart() { | |
cmd := exec.Command(s.path, args...) | ||
err := cmd.Start() | ||
if err != nil { | ||
fmt.Printf("Error restarting process: %v\n", err) | ||
log.Printf("Error restarting process: %v\n", err) | ||
return | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 startUpdate()
sets this path and then callsRestart()
There was a problem hiding this comment.
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
andRestart