[pacman-dev] [PATCH] libalpm: Give -U downloads a random .part name if needed

Allan McRae allan at archlinux.org
Sat Sep 4 00:33:15 UTC 2021


On 3/9/21 10:06 pm, Allan McRae wrote:
> From: morganamilo <morganamilo at archlinux.org>
> 
> archweb's download links all ended in /download. This cause all the temp
> files to be named download.part. With parallel downloads this results in
> multiple downloads to go to the same temp file and breaks the transaction.
> 
> Assign random temporary filenames to downloads from URLs that are either
> missing a filename, or if the filename does not contain at least three
> hyphens (as a well formed package filename does).
> 
> While this approach to determining when to use a temporary filename is
> not 100% foolproof, it does keep nice looking download progress bar names
> when a proper package filename is given. The only downside of not using
> temporary files when provided with a filename  with three or more hyphens
> is URLs created specifically to bypass temporary filename usage can not
> be downloaded in parallel. We probably do not want to download packages
> from such URLs anyway.
> 
> Fixes FS#71464
> 

<snip>

		STRDUP(payload->fileurl, url, FREE(payload); GOTO_ERR(handle,
ALPM_ERR_MEMORY, err));
> -			payload->allow_resume = 1;
> +
> +			c = strrchr(url, '/');
> +			while(*c) {
> +				if(*c == '-') {
> +					hyphen_count++;
> +				}
> +				c++;
> +			}
> +
> +			if(hyphen_count > 2) {


Changed all this to:

c = strrchr(url, '/');
if(strstr(c, ".pkg")) {
	/* we probably have a usable package filename to download to */

which is consistent with the hacky crap we do URL redirections...



More information about the pacman-dev mailing list