mirror of
https://github.com/ddworken/hishtory.git
synced 2024-11-22 16:24:00 +01:00
Fix updating on m1 darwin
For some reason, calling unlink() on the binary causes all future spawned processes to die with a "signal: killed" error. I have no idea why this happens, but it doesn't seem to be necessary to call unlink on darwin, so I'm just tweaking this to not call unlink on darwin. Also remove tidy from the pre-commit since macos ships with a truly ancient version of tidy
This commit is contained in:
parent
94c88c76fe
commit
edfbf7769e
@ -14,8 +14,3 @@ repos:
|
||||
entry: errcheck -exclude .errcheck_excludes.txt ./...
|
||||
language: system
|
||||
pass_filenames: false
|
||||
- id: html-tidy
|
||||
name: html-tidy
|
||||
entry: tidy -quiet -modify -indent -wrap 140 backend/web/landing/www/index.html
|
||||
language: system
|
||||
pass_filenames: false
|
||||
|
@ -521,20 +521,26 @@ func Update() error {
|
||||
}
|
||||
|
||||
// Unlink the existing binary so we can overwrite it even though it is still running
|
||||
homedir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get user's home directory: %v", err)
|
||||
}
|
||||
err = syscall.Unlink(path.Join(homedir, shared.HISHTORY_PATH, "hishtory"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unlink %s for update: %v", path.Join(homedir, shared.HISHTORY_PATH, "hishtory"), err)
|
||||
if runtime.GOOS == "linux" {
|
||||
homedir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get user's home directory: %v", err)
|
||||
}
|
||||
err = syscall.Unlink(path.Join(homedir, shared.HISHTORY_PATH, "hishtory"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unlink %s for update: %v", path.Join(homedir, shared.HISHTORY_PATH, "hishtory"), err)
|
||||
}
|
||||
}
|
||||
|
||||
// Install the new one
|
||||
cmd := exec.Command("chmod", "+x", "/tmp/hishtory-client")
|
||||
var stdout bytes.Buffer
|
||||
cmd.Stdout = &stdout
|
||||
var stderr bytes.Buffer
|
||||
cmd.Stderr = &stderr
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to chmod +x the update: %v", err)
|
||||
return fmt.Errorf("failed to chmod +x the update (out=%#v, err=%#v): %v", stdout.String(), stderr.String(), err)
|
||||
}
|
||||
cmd = exec.Command("/tmp/hishtory-client", "install")
|
||||
err = cmd.Run()
|
||||
|
Loading…
Reference in New Issue
Block a user