[PATCH v2] paccache: Support cleaning many thousands of candidates
Daniel M. Capella
polyzen at archlinux.org
Tue Jul 28 04:55:28 UTC 2020
On June 2, 2020 1:27:58 AM EDT, Leonid Bloch <lb.workbox at gmail.com> wrote:
> In situations when there are many thousands of candidates for
> deletion,
> paccache returns an "Argument list too long" error at the freed space
> calculation stage, because the expansion of the ${candidates[@]} array
> becomes too long for Bash.
>
> This commit fixes that problem, by getting the @SIZECMD@ arguments via
> `printf '%s\0' "${candidates[@]}" | xargs -0`, similarly to what is
> done
> for the (re)moving commands below.
>
> Signed-off-by: Leonid Bloch <lb.workbox at gmail.com>
> ---
> src/paccache.sh.in | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/paccache.sh.in b/src/paccache.sh.in
> index af901f4..1311fd7 100644
> --- a/src/paccache.sh.in
> +++ b/src/paccache.sh.in
> @@ -391,7 +391,8 @@ candidates=("${candtemp[@]}")
> unset candtemp
>
> # do this before we destroy anything
> -totalsaved=$(@SIZECMD@ "${candidates[@]}" | awk '{ sum += $1 } END {
> print sum }')
> +totalsaved=$(printf '%s\0' "${candidates[@]}" | xargs -0 @SIZECMD@ |
> + awk '{ sum += $1 } END { print sum }')
>
> # Exit immediately if a pipeline returns non-zero.
> set -o errexit
Merged, sorry for the wait.
--
Best,
Daniel <https://danielcapella.com>
More information about the pacman-contrib
mailing list