]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[downloader] Allow underlying downloads to provide detailed job progress
authorMichael Brown <mcb30@ipxe.org>
Tue, 5 Sep 2017 21:53:49 +0000 (22:53 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 5 Sep 2017 22:23:22 +0000 (23:23 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/downloader.c

index 35b5b0ac69f0e9c49ab57d20abfc2358404ac916..33737bfacb6cb91c1d84712a63854eee6cd33c77 100644 (file)
@@ -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;
 }