diff --git a/package/harvester-os/files/usr/sbin/harv-install b/package/harvester-os/files/usr/sbin/harv-install index 51c96a57f..e04e0158e 100755 --- a/package/harvester-os/files/usr/sbin/harv-install +++ b/package/harvester-os/files/usr/sbin/harv-install @@ -104,21 +104,7 @@ get_url() attempts=5 until [ "$n" -ge "$attempts" ] do - # Because `curl` command uses `\r` to overwrite the progress bar, - # so we should also consider `\r` when splitting the output. - # Hence, we use `startcurl` and `endcurl` to trigger replacing the progress bar. - # But, when we use `\r` to display, the header will be overwritten, so we need to print the header manually. - echo "% Total % Received % Xferd Average Speed Time Time Time Current" - echo " Dload Upload Total Spent Left Speed" - echo "startcurl" - curl -o $TO -fL ${FROM} 2>&1 - curl_result=$? - echo "endcurl" - - if [ "$curl_result" -eq 0 ]; then - break - fi - + curl -o $TO -fL ${FROM} && break n=$((n+1)) echo "Failed to download, retry attempt ${n} out of ${attempts}" sleep 2 diff --git a/pkg/console/util.go b/pkg/console/util.go index 13ad40f9f..25005be40 100644 --- a/pkg/console/util.go +++ b/pkg/console/util.go @@ -430,26 +430,11 @@ func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) { func printToPanelAndLog(g *gocui.Gui, panel string, logPrefix string, reader io.Reader, lock *sync.Mutex) { scanner := bufio.NewScanner(reader) scanner.Split(ScanLines) - currentPrinter := printToPanel for scanner.Scan() { logrus.Infof("%s: %s", logPrefix, scanner.Text()) lock.Lock() - text := scanner.Text() - - if strings.Contains(text, "startcurl") { - currentPrinter = printCurlProgressBarToPanel - lock.Unlock() - continue - } - if strings.Contains(text, "endcurl") { - currentPrinter = printToPanel - printToPanel(g, " ", panel) - lock.Unlock() - continue - } - - currentPrinter(g, text, panel) + printToPanel(g, scanner.Text(), panel) lock.Unlock() } } @@ -661,28 +646,6 @@ func printToPanel(g *gocui.Gui, message string, panelName string) { <-ch } -func printCurlProgressBarToPanel(g *gocui.Gui, message string, panelName string) { - // block printToPanel call in the same goroutine. - // This ensures messages are printed out in the calling order. - ch := make(chan struct{}) - - g.Update(func(g *gocui.Gui) error { - - defer func() { - ch <- struct{}{} - }() - - v, err := g.View(panelName) - if err != nil { - return err - } - v.Write(append([]byte{'\r'}, []byte(message)...)) - return nil - }) - - <-ch -} - func getRemoteConfig(configURL string) (*config.HarvesterConfig, error) { client := newProxyClient() b, err := getURL(client, configURL)