mirror of https://github.com/vitalif/grive2
Get progressbar::last back, do not print multiple 100% lines (fixes #104)
parent
67b5b05e17
commit
68e0e5afe5
|
@ -8,7 +8,7 @@
|
|||
namespace gr
|
||||
{
|
||||
|
||||
ProgressBar::ProgressBar(): showProgressBar(false)
|
||||
ProgressBar::ProgressBar(): showProgressBar(false), last(1000)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,10 @@ void ProgressBar::reportProgress(u64_t total, u64_t processed)
|
|||
double fraction = (double)processed/total;
|
||||
|
||||
int point = round(fraction*1000);
|
||||
if (this->last < 1000 || point != this->last)
|
||||
{
|
||||
// only print progress after >= 0.1% change
|
||||
this->last = point;
|
||||
|
||||
// 10 for prefix of percent and 22 for suffix of file size
|
||||
int availableSize = determineTerminalSize() - 32;
|
||||
|
@ -76,6 +80,7 @@ void ProgressBar::reportProgress(u64_t total, u64_t processed)
|
|||
putchar('\n');
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ private:
|
|||
static unsigned short int determineTerminalSize();
|
||||
|
||||
bool showProgressBar;
|
||||
int last;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue