@@ -327,8 +326,6 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
size_t howmany, size_t current)
{
- float timediff;
-
/* size of line to allocate for text printing (e.g. not progressbar) */
int infolen;
int digits, textlen;
@@ -342,32 +339,24 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
return;
}
- infolen = getcols() * 6 / 10;
- if (infolen < 50) {
- infolen = 50;
- }
-
if(percent == 0) {
- timediff = get_update_timediff(1);
+ get_update_timediff(1);
+ } else if(percent == 100) {
+ /* no need for timediff update, but unconditionally continue unless we
+ * already completed on a previous call */
+ if(prevpercent == 100) {
+ return;
+ }
} else {
- timediff = get_update_timediff(0);
- }
-
- if(percent > 0 && percent < 100 && timediff > 0) {
- /* only update the progress bar when
- * a) we first start
- * b) we end the progress
- * c) it has been long enough since the last call
- */
- return;
+ if(!pkgname || percent == prevpercent || get_update_timediff(0) < UPDATE_SPEED_SEC) {
+ /* only update the progress bar when we have a package name, the
+ * percentage has changed, and it has been long enough. */
+ return;
+ }
}
- /* if no pkgname, percent is too high or unchanged, then return */
- if(!pkgname || percent == prevpercent) {
- return;
- }
+ prevpercent = percent;
- prevpercent=percent;
/* set text of message to display */
switch (event) {
case PM_TRANS_PROGRESS_ADD_START:
@@ -389,6 +378,11 @@ void cb_trans_progress(pmtransprog_t event, const char *pkgname, int percent,
return;
}