Pipe ctx into the Update function

This commit is contained in:
David Dworken 2022-09-21 20:20:43 -07:00
parent 8002c5e942
commit d226fab7ec
2 changed files with 3 additions and 6 deletions

View File

@ -637,7 +637,7 @@ func GetDownloadData() (shared.UpdateInfo, error) {
return downloadData, nil
}
func Update() error {
func Update(ctx *context.Context) error {
// Download the binary
downloadData, err := GetDownloadData()
if err != nil {
@ -664,10 +664,7 @@ func Update() error {
// Unlink the existing binary so we can overwrite it even though it is still running
if runtime.GOOS == "linux" {
homedir, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("failed to get user's home directory: %v", err)
}
homedir := hctx.GetHome(ctx)
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)

View File

@ -90,7 +90,7 @@ func main() {
}
fmt.Printf("Commit Hash: %s\n", GitCommit)
case "update":
lib.CheckFatalError(lib.Update())
lib.CheckFatalError(lib.Update(hctx.MakeContext()))
case "-h":
fallthrough
case "help":