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

[cli] Only update progress when percentage goes up #2979

Merged
merged 1 commit into from
Mar 30, 2023

Conversation

sharder996
Copy link
Contributor

Fixes #1532

@@ -522,6 +522,7 @@ void mp::LXDVMImageVault::poll_download_operation(const QJsonObject& json_reply,
.arg(json_reply["metadata"].toObject()["id"].toString()));

// Instead of polling, need to use websockets to get events
auto last_download_progress = -2;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use -2 because there are two different states that are being checked here. The above reply can either return a percentage for download progress (located under download_progress -> rootfs in the json reply, or a percentage for metadata download progress (located under download_progress -> metadata. The above helper function parse_percent_as_int() will return -1 when downloading metadata, so a starting value of -2 is used so that the downloading message will still be displayed in the cli.

@codecov
Copy link

codecov bot commented Mar 20, 2023

Codecov Report

Merging #2979 (36e0223) into main (6ef9ce3) will decrease coverage by 0.03%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##             main    #2979      +/-   ##
==========================================
- Coverage   86.89%   86.87%   -0.03%     
==========================================
  Files         231      231              
  Lines       12042    12049       +7     
==========================================
+ Hits        10464    10467       +3     
- Misses       1578     1582       +4     
Impacted Files Coverage Δ
src/xz_decoder/xz_image_decoder.cpp 0.00% <0.00%> (ø)
src/platform/backends/lxd/lxd_vm_image_vault.cpp 94.54% <75.00%> (-0.31%) ⬇️
src/network/url_downloader.cpp 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@townsend2010 townsend2010 left a comment

Choose a reason for hiding this comment

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

Hey @sharder996!

Thanks for this! I tried this out on Windows and can say it's much better than before. That said, I'm still seeing an occasional flicker. Is that expected?

@sharder996
Copy link
Contributor Author

Hey @townsend2010, thanks for the review!

It shouldn't be flickering, except when the percentage changes. The whole line gets updated then so it may flash briefly. Also, this PR only affects the download percentage message so other messages, such as those that have a spinner, may still flicker because of how often they get updated.

Copy link
Contributor

@townsend2010 townsend2010 left a comment

Choose a reason for hiding this comment

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

Ok, makes sense, thanks! LGTM!

bors merge

@bors bors bot merged commit 29a575d into main Mar 30, 2023
@bors bors bot deleted the only-update-progress-when-changed branch March 30, 2023 21:15
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.

[windows] download progress flickering
2 participants