fixes in displaying download time remaining
This commit is contained in:
parent
e53a71fc3a
commit
9e8ec2e729
@ -912,15 +912,21 @@ namespace Pamac {
|
|||||||
text.append (previous_textbar);
|
text.append (previous_textbar);
|
||||||
timer.start ();
|
timer.start ();
|
||||||
} else {
|
} else {
|
||||||
|
if (timer.elapsed () > 0) {
|
||||||
download_rate = ((download_rate * rates_nb) + (uint64) ((xfered - previous_xfered) / timer.elapsed ())) / (rates_nb + 1);
|
download_rate = ((download_rate * rates_nb) + (uint64) ((xfered - previous_xfered) / timer.elapsed ())) / (rates_nb + 1);
|
||||||
rates_nb++;
|
rates_nb++;
|
||||||
|
}
|
||||||
previous_xfered = xfered;
|
previous_xfered = xfered;
|
||||||
uint64 downloaded_total = xfered + already_downloaded;
|
uint64 downloaded_total = xfered + already_downloaded;
|
||||||
fraction = (float) downloaded_total / total_download;
|
fraction = (float) downloaded_total / total_download;
|
||||||
if (fraction <= 1) {
|
if (fraction <= 1) {
|
||||||
text.append ("%s/%s ".printf (format_size (xfered + already_downloaded), format_size (total_download)));
|
text.append ("%s/%s ".printf (format_size (xfered + already_downloaded), format_size (total_download)));
|
||||||
uint64 remaining_seconds = (total_download - downloaded_total) / download_rate;
|
uint64 remaining_seconds = 0;
|
||||||
if (remaining_seconds > 9) {
|
if (download_rate > 0) {
|
||||||
|
remaining_seconds = (total_download - downloaded_total) / download_rate;
|
||||||
|
}
|
||||||
|
// display remaining time after 5s and only if more than 10s are remaining
|
||||||
|
if (remaining_seconds > 9 && rates_nb > 9) {
|
||||||
if (remaining_seconds <= 50) {
|
if (remaining_seconds <= 50) {
|
||||||
text.append (dgettext (null, "About %u seconds remaining").printf ((uint) Math.ceilf ((float) remaining_seconds / 10) * 10));
|
text.append (dgettext (null, "About %u seconds remaining").printf ((uint) Math.ceilf ((float) remaining_seconds / 10) * 10));
|
||||||
} else {
|
} else {
|
||||||
@ -951,14 +957,20 @@ namespace Pamac {
|
|||||||
fraction = 1;
|
fraction = 1;
|
||||||
previous_filename = "";
|
previous_filename = "";
|
||||||
} else {
|
} else {
|
||||||
|
if (timer.elapsed () > 0) {
|
||||||
download_rate = ((download_rate * rates_nb) + (uint64) ((xfered - previous_xfered) / timer.elapsed ())) / (rates_nb + 1);
|
download_rate = ((download_rate * rates_nb) + (uint64) ((xfered - previous_xfered) / timer.elapsed ())) / (rates_nb + 1);
|
||||||
previous_xfered = xfered;
|
|
||||||
rates_nb++;
|
rates_nb++;
|
||||||
|
}
|
||||||
|
previous_xfered = xfered;
|
||||||
fraction = (float) xfered / total;
|
fraction = (float) xfered / total;
|
||||||
if (fraction <= 1) {
|
if (fraction <= 1) {
|
||||||
text.append ("%s/%s ".printf (format_size (xfered), format_size (total)));
|
text.append ("%s/%s ".printf (format_size (xfered), format_size (total)));
|
||||||
uint64 remaining_seconds = (total - xfered) / download_rate;
|
uint64 remaining_seconds = 0;
|
||||||
if (remaining_seconds > 9) {
|
if (download_rate > 0) {
|
||||||
|
remaining_seconds = (total - xfered) / download_rate;
|
||||||
|
}
|
||||||
|
// display remaining time after 5s and only if more than 10s are remaining
|
||||||
|
if (remaining_seconds > 9 && rates_nb > 9) {
|
||||||
if (remaining_seconds <= 50) {
|
if (remaining_seconds <= 50) {
|
||||||
text.append (dgettext (null, "About %u seconds remaining").printf ((uint) Math.ceilf ((float) remaining_seconds / 10) * 10));
|
text.append (dgettext (null, "About %u seconds remaining").printf ((uint) Math.ceilf ((float) remaining_seconds / 10) * 10));
|
||||||
} else {
|
} else {
|
||||||
@ -1196,6 +1208,7 @@ namespace Pamac {
|
|||||||
if (err.message == dgettext (null, "Authentication failed")) {
|
if (err.message == dgettext (null, "Authentication failed")) {
|
||||||
finished (false);
|
finished (false);
|
||||||
} else {
|
} else {
|
||||||
|
clear_lists ();
|
||||||
finished (true);
|
finished (true);
|
||||||
}
|
}
|
||||||
handle_error (err);
|
handle_error (err);
|
||||||
@ -1207,7 +1220,7 @@ namespace Pamac {
|
|||||||
|
|
||||||
void on_term_child_exited (int status) {
|
void on_term_child_exited (int status) {
|
||||||
Source.remove (pulse_timeout_id);
|
Source.remove (pulse_timeout_id);
|
||||||
to_build.remove_all ();
|
clear_lists ();
|
||||||
// let the time to the daemon to update databases
|
// let the time to the daemon to update databases
|
||||||
Timeout.add (1000, () => {
|
Timeout.add (1000, () => {
|
||||||
finished (true);
|
finished (true);
|
||||||
|
Loading…
Reference in New Issue
Block a user