mirror of
https://github.com/ddworken/hishtory.git
synced 2025-01-22 22:28:51 +01:00
Pipe ctx into the Update function
This commit is contained in:
parent
8002c5e942
commit
d226fab7ec
@ -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)
|
||||
|
@ -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":
|
||||
|
Loading…
Reference in New Issue
Block a user