[pacman-dev] [PATCH] libalpm: Give -U downlaoads a random .part name
archweb's download links all end in /download. This causes all the temp files to be named download.part. With parallel downloads this causes multiple downloads to go to the same temp file and breaks. Note that the final file name is not changed so once the download is complete the download is given its proper name. Fixes FS#71464 --- lib/libalpm/dload.c | 8 ++++---- lib/libalpm/dload.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index ca6be7b6..6bccabf4 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -767,7 +767,7 @@ static int curl_add_payload(alpm_handle_t *handle, CURLM *curlm, GOTO_ERR(handle, ALPM_ERR_SERVER_BAD_URL, cleanup); } - if(payload->remote_name && strlen(payload->remote_name) > 0) { + if(!payload->random_partfile && payload->remote_name && strlen(payload->remote_name) > 0) { if(!payload->destfile_name) { payload->destfile_name = get_fullpath(localpath, payload->remote_name, ""); } @@ -776,8 +776,8 @@ static int curl_add_payload(alpm_handle_t *handle, CURLM *curlm, goto cleanup; } } else { - /* URL doesn't contain a filename, so make a tempfile. We can't support - * resuming this kind of download; partial transfers will be destroyed */ + /* We want a random filename or URL doesn't contain a filename, so make a tempfile. + * We can't support resuming this kind of download; partial transfers will be destroyed */ payload->unlink_on_fail = 1; payload->localf = create_tempfile(payload, localpath); @@ -990,7 +990,7 @@ int SYMEXPORT alpm_fetch_pkgurl(alpm_handle_t *handle, const alpm_list_t *urls, ASSERT(url, GOTO_ERR(handle, ALPM_ERR_WRONG_ARGS, err)); CALLOC(payload, 1, sizeof(*payload), GOTO_ERR(handle, ALPM_ERR_MEMORY, err)); STRDUP(payload->fileurl, url, FREE(payload); GOTO_ERR(handle, ALPM_ERR_MEMORY, err)); - payload->allow_resume = 1; + payload->random_partfile = 1; payload->handle = handle; payload->trust_remote_name = 1; payload->download_signature = (handle->siglevel & ALPM_SIG_PACKAGE); diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h index 8f3d17b4..dfeb7902 100644 --- a/lib/libalpm/dload.h +++ b/lib/libalpm/dload.h @@ -44,6 +44,7 @@ struct dload_payload { off_t prevprogress; int force; int allow_resume; + int random_partfile; int errors_ok; int unlink_on_fail; int trust_remote_name; -- 2.32.0
On 12/7/21 2:28 am, morganamilo wrote:
archweb's download links all end in /download. This causes all the temp files to be named download.part. With parallel downloads this causes multiple downloads to go to the same temp file and breaks.
Note that the final file name is not changed so once the download is complete the download is given its proper name.
Fixes FS#71464
So... I was going to accept this but: $ sudo ./build/pacman -U https://syd.mirror.rackspace.com/archlinux/core/os/x86_64/bash-5.1.008-1-x86... [sudo] password for allan: :: Retrieving packages... alpmtmp.pXDazo 1693.6 KiB 2.94 MiB/s 00:01 [######################] 100% loading packages... So this patch makes things worse for perfectly well defined URLs. Updated patch that I find acceptable incoming.
participants (2)
-
Allan McRae
-
morganamilo