Parametrise the different ways in which the payload is reset
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 <mysatyre@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
c3b954e7b9
commit
e83e868a77
3 changed files with 12 additions and 3 deletions
|
@ -722,4 +722,14 @@ void _alpm_dload_payload_reset(struct dload_payload *payload)
|
||||||
memset(payload, '\0', sizeof(*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: */
|
/* vim: set noet: */
|
||||||
|
|
|
@ -47,6 +47,7 @@ struct dload_payload {
|
||||||
};
|
};
|
||||||
|
|
||||||
void _alpm_dload_payload_reset(struct dload_payload *payload);
|
void _alpm_dload_payload_reset(struct dload_payload *payload);
|
||||||
|
void _alpm_dload_payload_reset_for_retry(struct dload_payload *payload);
|
||||||
|
|
||||||
int _alpm_download(struct dload_payload *payload, const char *localpath,
|
int _alpm_download(struct dload_payload *payload, const char *localpath,
|
||||||
char **final_file, const char **final_url);
|
char **final_file, const char **final_url);
|
||||||
|
|
|
@ -946,9 +946,7 @@ static int download_single_file(alpm_handle_t *handle, struct dload_payload *pay
|
||||||
EVENT(handle, &event);
|
EVENT(handle, &event);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
_alpm_dload_payload_reset_for_retry(payload);
|
||||||
FREE(payload->fileurl);
|
|
||||||
payload->unlink_on_fail = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event.type = ALPM_EVENT_PKGDOWNLOAD_FAILED;
|
event.type = ALPM_EVENT_PKGDOWNLOAD_FAILED;
|
||||||
|
|
Loading…
Add table
Reference in a new issue