mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-25 18:55:28 -06:00
remove go-getter
This commit is contained in:
@@ -3,8 +3,8 @@ package updates
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
|
|
||||||
"github.com/kardianos/osext"
|
"github.com/kardianos/osext"
|
||||||
|
|
||||||
"github.com/jesseduffield/go-getter"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/config"
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
"github.com/jesseduffield/lazygit/pkg/i18n"
|
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||||
@@ -254,17 +253,34 @@ func (u *Updater) update(newVersion string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *Updater) downloadAndInstall(rawUrl string) error {
|
func (u *Updater) downloadAndInstall(rawUrl string) error {
|
||||||
url, err := url.Parse(rawUrl)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
g := new(getter.HttpGetter)
|
|
||||||
configDir := u.Config.GetUserConfigDir()
|
configDir := u.Config.GetUserConfigDir()
|
||||||
u.Log.Info("Download directory is " + configDir)
|
u.Log.Info("Download directory is " + configDir)
|
||||||
|
|
||||||
// Get it!
|
tempPath := filepath.Join(configDir, "temp_lazygit")
|
||||||
if err := g.Get(configDir, url); err != nil {
|
u.Log.Info("Temp path to binary is " + tempPath)
|
||||||
|
|
||||||
|
// Create the file
|
||||||
|
out, err := os.Create(tempPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer out.Close()
|
||||||
|
|
||||||
|
// Get the data
|
||||||
|
resp, err := http.Get(rawUrl)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// Check server response
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return fmt.Errorf("error while trying to download latest lazygit: %s", resp.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the body to file
|
||||||
|
_, err = io.Copy(out, resp.Body)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,12 +291,7 @@ func (u *Updater) downloadAndInstall(rawUrl string) error {
|
|||||||
}
|
}
|
||||||
u.Log.Info("Binary path is " + binaryPath)
|
u.Log.Info("Binary path is " + binaryPath)
|
||||||
|
|
||||||
binaryName := filepath.Base(binaryPath)
|
|
||||||
u.Log.Info("Binary name is " + binaryName)
|
|
||||||
|
|
||||||
// Verify the main file exists
|
// Verify the main file exists
|
||||||
tempPath := filepath.Join(configDir, binaryName)
|
|
||||||
u.Log.Info("Temp path to binary is " + tempPath)
|
|
||||||
if _, err := os.Stat(tempPath); err != nil {
|
if _, err := os.Stat(tempPath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user