Skip to content

Commit

Permalink
[downloader] Allow underlying downloads to provide detailed job progress
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Sep 5, 2017
1 parent e30cc5e commit a258b08
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/core/downloader.c
Expand Up @@ -111,13 +111,20 @@ static void downloader_finished ( struct downloader *downloader, int rc ) {
*/
static int downloader_progress ( struct downloader *downloader,
struct job_progress *progress ) {
int rc;

/* Allow data transfer to provide an accurate description */
if ( ( rc = job_progress ( &downloader->xfer, progress ) ) != 0 )
return rc;

/* This is not entirely accurate, since downloaded data may
* arrive out of order (e.g. with multicast protocols), but
* it's a reasonable first approximation.
*/
progress->completed = downloader->buffer.pos;
progress->total = downloader->buffer.len;
if ( ! progress->total ) {
progress->completed = downloader->buffer.pos;
progress->total = downloader->buffer.len;
}

return 0;
}
Expand Down

0 comments on commit a258b08

Please sign in to comment.