Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make curl progress bar correctly shows on the gui #882

Merged
merged 2 commits into from
Nov 29, 2024

Conversation

Yu-Jack
Copy link
Contributor

@Yu-Jack Yu-Jack commented Nov 13, 2024

Problem:
When downloading ISO, the progress bar doesn't show well. The reason is that curl uses \r to overwrite and print the progress bar. And the console.log in /oem/install is not aligned.

image

Solution:
We should consider the \r character as well when scanning. And add a tag to switch different printers to print the messages.

Related Issue:
harvester/harvester#5990

Test plan:

Install it with PXE, and check progress bar should display correctly.

Version 1

demo.mov

Console log in /oem/install/console.log

After

image

Version 2

Same as Version 1, but I use "Total Spent Left Speed" as flag to trigger different printers. Then, we don't have duplicated header in /oem/install/console.log. But ... we still need the endcurl to change back to original printer.

Version 3 (Recommended Way)

Don't use \r to print the curl progress bar, just use \n. It will look like console.log in Version 1. But, if user's network bandwidth is not well, the log file and console would be large.

demo-01.mov

image

for scanner.Scan() {
printToPanel(g, scanner.Text(), upgradePanel)
}
scanner = bufio.NewScanner(stderr)
scanner.Split(bufio.ScanLines)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, when using bufio.NewScanner, the bufio.ScanLines is already split function by default. We don't need to set it up again.

@Yu-Jack Yu-Jack self-assigned this Nov 14, 2024
@Yu-Jack Yu-Jack requested a review from bk201 November 27, 2024 03:54
@bk201 bk201 requested a review from tserong November 27, 2024 08:16
Signed-off-by: Jack Yu <[email protected]>
Copy link
Contributor

@tserong tserong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (untested). This should also help me with harvester/harvester#5095 :-)

@bk201 bk201 merged commit c9ae52b into harvester:master Nov 29, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants