From e83e868a77865d42a33076605f9a90a165f7c93a Mon Sep 17 00:00:00 2001 From: Martin Kühne Date: Mon, 17 Oct 2016 16:40:37 +0200 Subject: Parametrise the different ways in which the payload is reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In FS#43434, Downloads which fail and are restarted on a different server will resume and may display a negative download speed. The payload's progress in libalpm was not properly reset which ultimately caused terminal noise because the line width calculation assumes positive download speeds. This patch fixes the incomplete reset of the payload by mimicing what be_sync.c:alpm_db_update() does over in sync.c:download_single_file(). The new dload.c:_alpm_dload_payload_reset_for_retry() extends beyond the current behavior by updating initial_size and prevprogress for this case. This makes pacman reset the progress properly in the next invocation of the callback and display positive download speeds. Fixes FS#43434. Signed-off-by: Martin Kühne Signed-off-by: Allan McRae --- lib/libalpm/dload.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/libalpm/dload.c') diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index ccd70d99..e8896098 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -722,4 +722,14 @@ void _alpm_dload_payload_reset(struct dload_payload *payload) memset(payload, '\0', sizeof(*payload)); } +void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload) +{ + ASSERT(payload, return); + + FREE(payload->fileurl); + payload->initial_size += payload->prevprogress; + payload->prevprogress = 0; + payload->unlink_on_fail = 0; +} + /* vim: set noet: */ -- cgit v1.2.3-24-g4f1b