Skip to content

Commit 89ff22a

Browse files
Merge branch 'PluginTimeout' into dev
2 parents 4579428 + 6f78964 commit 89ff22a

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

internal/action/command.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,29 @@ func (h *BufPane) PluginCmd(args []string) {
107107
return
108108
}
109109

110+
switch args[0] {
111+
case "install":
112+
InfoBar.Message("Downloading plugin, please wait...")
113+
case "remove":
114+
case "update":
115+
InfoBar.Message("Updating plugins, please wait...")
116+
case "available":
117+
InfoBar.Message("Fetching plugins, please wait...")
118+
case "list":
119+
case "search":
120+
InfoBar.Message("Fetching plugins, please wait...")
121+
default:
122+
InfoBar.Error("Invalid plugin command:", args[0])
123+
}
124+
125+
// NOTE: Display the message in info bar immediately before we get hang in PluginCommand()
126+
// Ideally we should lock it but it seems like main func in micro.go is constantly locking it
127+
// Locking it here will cause a deadlock
128+
// screen.Lock()
129+
InfoBar.Display()
130+
screen.Show()
131+
// screen.Unlock()
132+
110133
if h.Buf.Type != buffer.BTLog {
111134
h.OpenLogBuf()
112135
}

internal/config/plugin_installer.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ func (pc PluginChannels) Fetch(out io.Writer) PluginPackages {
127127

128128
// Fetch retrieves all available PluginPackages from the given channel
129129
func (pc PluginChannel) Fetch(out io.Writer) PluginPackages {
130-
client := http.Client {
131-
Timeout: 10 * time.Second,
130+
client := http.Client{
131+
Timeout: 30 * time.Second,
132132
}
133133
resp, err := client.Get(string(pc))
134134
if err != nil {
@@ -150,8 +150,8 @@ func (pc PluginChannel) Fetch(out io.Writer) PluginPackages {
150150

151151
// Fetch retrieves all available PluginPackages from the given repository
152152
func (pr PluginRepository) Fetch(out io.Writer) PluginPackages {
153-
client := http.Client {
154-
Timeout: 10 * time.Second,
153+
client := http.Client{
154+
Timeout: 30 * time.Second,
155155
}
156156
resp, err := client.Get(string(pr))
157157
if err != nil {
@@ -398,8 +398,8 @@ func GetInstalledPluginVersion(name string) string {
398398
// DownloadAndInstall downloads and installs the given plugin and version
399399
func (pv *PluginVersion) DownloadAndInstall(out io.Writer) error {
400400
fmt.Fprintf(out, "Downloading %q (%s) from %q\n", pv.pack.Name, pv.Version, pv.Url)
401-
client := http.Client {
402-
Timeout: 10 * time.Second,
401+
client := http.Client{
402+
Timeout: 30 * time.Second,
403403
}
404404
resp, err := client.Get(pv.Url)
405405
if err != nil {
@@ -650,6 +650,7 @@ func UpdatePlugins(out io.Writer, plugins []string) {
650650
func PluginCommand(out io.Writer, cmd string, args []string) {
651651
switch cmd {
652652
case "install":
653+
fmt.Fprintln(out, "Downloading plugin, please wait...")
653654
installedVersions := GetInstalledVersions(false)
654655
for _, plugin := range args {
655656
pp := GetAllPluginPackages(out).Get(plugin)
@@ -693,6 +694,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) {
693694
fmt.Fprintln(out, "No plugins removed")
694695
}
695696
case "update":
697+
fmt.Fprintln(out, "Updating plugins, please wait...")
696698
UpdatePlugins(out, args)
697699
case "list":
698700
plugins := GetInstalledVersions(false)
@@ -701,6 +703,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) {
701703
fmt.Fprintf(out, "%s (%s)\n", p.Pack().Name, p.Version)
702704
}
703705
case "search":
706+
fmt.Fprintln(out, "Fetching plugins, please wait...")
704707
plugins := SearchPlugin(out, args)
705708
fmt.Fprintln(out, len(plugins), " plugins found")
706709
for _, p := range plugins {
@@ -709,6 +712,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) {
709712
}
710713
fmt.Fprintln(out, "----------------")
711714
case "available":
715+
fmt.Fprintln(out, "Fetching plugins, please wait...")
712716
packages := GetAllPluginPackages(out)
713717
fmt.Fprintln(out, "Available Plugins:")
714718
for _, pkg := range packages {

internal/screen/screen.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ func SetContent(x, y int, mainc rune, combc []rune, style tcell.Style) {
121121
}
122122
}
123123

124+
func Show() {
125+
Screen.Show()
126+
}
127+
124128
// TempFini shuts the screen down temporarily
125129
func TempFini() bool {
126130
screenWasNil := Screen == nil

0 commit comments

Comments
 (0)