xbps_fetch_file: set bytes downloaded correctly for the fetch client cb.
This commit is contained in:
parent
e7562fa72d
commit
8be527cbdf
@ -57,7 +57,7 @@ stat_eta(const struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
elapsed = xfer->last.tv_sec - xfer->start.tv_sec;
|
||||
received = xfpd->file_dloaded - xfpd->file_offset;
|
||||
expected = xfpd->file_size - xfpd->file_dloaded;
|
||||
eta = (long)(elapsed * expected / received);
|
||||
eta = (long)(elapsed * (long)expected / (long)received);
|
||||
if (eta > 3600)
|
||||
snprintf(str, sizeof str, "%02ldh%02ldm",
|
||||
eta / 3600, (eta % 3600) / 60);
|
||||
@ -124,10 +124,7 @@ stat_display(const struct xbps_fetch_cb_data *xfpd, void *cbdata)
|
||||
(int)((double)(100.0 *
|
||||
(double)xfpd->file_dloaded) / (double)xfpd->file_size), totsize);
|
||||
fprintf(stderr," %s", stat_bps(xfpd, xfer));
|
||||
if (xfpd->file_size > 0 && xfpd->file_dloaded > 0 &&
|
||||
xfer->last.tv_sec >= xfer->start.tv_sec + 10)
|
||||
fprintf(stderr," ETA: %s", stat_eta(xfpd, xfer));
|
||||
|
||||
fprintf(stderr," ETA: %s", stat_eta(xfpd, xfer));
|
||||
fprintf(stderr,"\033[K");
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ xbps_fetch_file(const char *uri,
|
||||
* and let the user know that the transfer is going to start
|
||||
* immediately.
|
||||
*/
|
||||
xbps_set_cb_fetch(url_st.size, url->offset, -1,
|
||||
xbps_set_cb_fetch(url_st.size, url->offset, url->offset,
|
||||
filename, true, false, false);
|
||||
/*
|
||||
* Start fetching requested file.
|
||||
@ -282,7 +282,7 @@ xbps_fetch_file(const char *uri,
|
||||
* Let the fetch progress callback know that
|
||||
* we are sucking more bytes from it.
|
||||
*/
|
||||
xbps_set_cb_fetch(url_st.size, url->offset, bytes_dload,
|
||||
xbps_set_cb_fetch(url_st.size, url->offset, url->offset + bytes_dload,
|
||||
filename, false, true, false);
|
||||
}
|
||||
if (bytes_read == -1) {
|
||||
|
Loading…
Reference in New Issue
Block a user