From 1e3c088c2e14c7211e77ad73201458418fd34091 Mon Sep 17 00:00:00 2001 From: Olivier Brunel Date: Thu, 31 Jul 2014 19:42:28 +0200 Subject: alpm: Fix wrong xferred/total sizes when resuming downloads When a package is already partially downloaded in the cache, its download size will only be of what's left to be downloaded. Since pkg->download_size is what's used when calculating the total download size for the totaldl callback, same thing apply. However, the download progress callback was including this initial size, which would thus lead to invalid values (and percentage) used in frontends. That is, the progress bar could e.g. go further than 100% In the case of pacman, there is a sanity check for different historical reason (44a57c89), so before the possible "overflow" was noticed, the total download size/progress reported was wrong. Once caught, the TotalDownload option was ignored and it would use individual file download values as fallback instead. Signed-off-by: Olivier Brunel Signed-off-by: Allan McRae --- lib/libalpm/dload.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index c5a56b56..1f8070c2 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -131,7 +131,9 @@ static int dload_progress_cb(void *file, double dltotal, double dlnow, payload->handle->dlcb(payload->remote_name, 0, (off_t)dltotal); } - payload->handle->dlcb(payload->remote_name, current_size, total_size); + /* do NOT include initial_size since it wasn't part of the package's + * download_size (nor included in the total download size callback) */ + payload->handle->dlcb(payload->remote_name, (off_t)dlnow, (off_t)dltotal); payload->prevprogress = current_size; -- cgit v1.2.3-70-g09d2