mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-19 19:37:59 +02: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
|
return downloadData, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Update() error {
|
func Update(ctx *context.Context) error {
|
||||||
// Download the binary
|
// Download the binary
|
||||||
downloadData, err := GetDownloadData()
|
downloadData, err := GetDownloadData()
|
||||||
if err != nil {
|
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
|
// Unlink the existing binary so we can overwrite it even though it is still running
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
homedir, err := os.UserHomeDir()
|
homedir := hctx.GetHome(ctx)
|
||||||
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"))
|
err = syscall.Unlink(path.Join(homedir, shared.HISHTORY_PATH, "hishtory"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to unlink %s for update: %v", path.Join(homedir, shared.HISHTORY_PATH, "hishtory"), err)
|
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)
|
fmt.Printf("Commit Hash: %s\n", GitCommit)
|
||||||
case "update":
|
case "update":
|
||||||
lib.CheckFatalError(lib.Update())
|
lib.CheckFatalError(lib.Update(hctx.MakeContext()))
|
||||||
case "-h":
|
case "-h":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "help":
|
case "help":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user