Fix auth segfault, remove 1/1000 progressbar interval (fixes #103)

pull/126/head
Vitaliy Filippov 2016-09-30 01:14:50 +03:00
parent f27e3724de
commit 67b5b05e17
3 changed files with 36 additions and 39 deletions

View File

@ -159,6 +159,8 @@ std::size_t CurlAgent::Receive( void* ptr, size_t size, size_t nmemb, CurlAgent
int CurlAgent::progress_callback( CurlAgent *pthis, curl_off_t totalDownload, curl_off_t finishedDownload, curl_off_t totalUpload, curl_off_t finishedUpload )
{
// Only report download progress when set explicitly
if ( pthis->m_pb )
{
totalDownload = pthis->m_pimpl->total_download;
if ( !totalUpload )
totalUpload = pthis->m_pimpl->total_upload;
@ -166,6 +168,7 @@ int CurlAgent::progress_callback( CurlAgent *pthis, curl_off_t totalDownload, cu
totalDownload > 0 ? totalDownload : totalUpload,
totalDownload > 0 ? finishedDownload : finishedUpload
);
}
return 0;
}

View File

@ -8,7 +8,7 @@
namespace gr
{
ProgressBar::ProgressBar(): showProgressBar(false), last(1000)
ProgressBar::ProgressBar(): showProgressBar(false)
{
}
@ -48,10 +48,6 @@ void ProgressBar::reportProgress(u64_t total, u64_t processed)
double fraction = (double)processed/total;
int point = round(fraction*1000);
if (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;
@ -80,7 +76,6 @@ void ProgressBar::reportProgress(u64_t total, u64_t processed)
putchar('\n');
fflush(stdout);
}
}
}
}

View File

@ -18,7 +18,6 @@ private:
static unsigned short int determineTerminalSize();
bool showProgressBar;
int last;
};
}