Bugzilla – Attachment 94423 Details for
Bug 168935
Yast package manager should show download rate
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
[patch]
Adds transfer rates (avg and of last period/second) to the download report
media-curl-xfer-rate.diff (text/plain), 3.42 KB, created by
Marius Tomaschewski
on 2006-07-25 12:19:09 UTC
(
hide
)
Description:
Adds transfer rates (avg and of last period/second) to the download report
Filename:
MIME Type:
Creator:
Marius Tomaschewski
Created:
2006-07-25 12:19:09 UTC
Size:
3.42 KB
patch
obsolete
>Index: ZYppCallbacks.h >=================================================================== >--- ZYppCallbacks.h (Revision 3834) >+++ ZYppCallbacks.h (Arbeitskopie) >@@ -224,7 +224,8 @@ > > virtual void start( Url file, Pathname localfile ) {} > >- virtual bool progress(int value, Url file) >+ virtual bool progress(int value, Url file, double dbps_avg = 0, >+ double dbps_now = 0) > { return true; } > > virtual Action problem( >Index: media/MediaCurl.cc >=================================================================== >--- media/MediaCurl.cc (Revision 3834) >+++ media/MediaCurl.cc (Arbeitskopie) >@@ -91,6 +91,7 @@ > , reached(false) > , report(_report) > , ltime( time(NULL)) >+ , secs( 0) > , dload( 0) > , uload( 0) > , url(_url) >@@ -99,6 +100,7 @@ > bool reached; > callback::SendReport<DownloadProgressReport> *report; > time_t ltime; >+ long secs; > double dload; > double uload; > zypp::Url url; >@@ -1035,16 +1037,54 @@ > // > // DESCRIPTION : Progress callback triggered from MediaCurl::getFile > // >-int MediaCurl::progressCallback( void *clientp, double dltotal, double dlnow, >- double ultotal, double ulnow ) >+int MediaCurl::progressCallback( void *clientp, >+ double dltotal, double dlnow, >+ double ultotal, double ulnow) > { > ProgressData *pdata = reinterpret_cast<ProgressData *>(clientp); > if( pdata) > { >+ double drate_avg = 0; >+ double drate_now = 0; >+ time_t now = time(NULL); >+ if( now > 0) >+ { >+ // reset time of last change in case initial time() >+ // failed or the time was adjusted (goes backward) >+ if( pdata->ltime <= 0 || pdata->ltime > now) >+ { >+ pdata->ltime = now; >+ } >+ >+ // >+ // dif: this callback is called every seconds, but >+ // there is also some run time of the callback code >+ // and it can happen that we "step over" a second. >+ // >+ // start time counting as soon as first data arrives >+ // (skip the connection / redirection time at begin) >+ // >+ time_t dif = 1; >+ if( pdata->secs > 0 || dlnow > 0 || ulnow > 0) >+ { >+ dif = (now - pdata->ltime); >+ dif = dif > 1 ? dif : 1; >+ >+ pdata->secs += dif; >+ } >+ >+ if( pdata->secs > 0) >+ drate_avg = (dlnow / pdata->secs); >+ >+ if( dlnow > pdata->dload) >+ drate_now = ((dlnow - pdata->dload) / dif); >+ } >+ > // send progress report first, abort transfer if requested > if( pdata->report) > { >- if (! (*(pdata->report))->progress(int( dlnow * 100 / dltotal ), pdata->url)) >+ if (! (*(pdata->report))->progress(int( dlnow * 100 / dltotal ), >+ pdata->url, drate_avg, drate_now)) > { > return 1; // abort transfer > } >@@ -1053,16 +1093,10 @@ > // check if we there is a timeout set > if( pdata->timeout > 0) > { >- time_t now = time(NULL); > if( now > 0) > { > bool progress = false; > >- // reset time of last change in case initial time() >- // failed or the time was adjusted (goes backward) >- if( pdata->ltime <= 0 || pdata->ltime > now) >- pdata->ltime = now; >- > // update download data if changed, mark progress > if( dlnow != pdata->dload) > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 168935
:
94423
|
118862
|
199663
|
199664