Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/common.sh
diff options
context:
space:
mode:
authorFelix Yan <felixonmars@archlinux.org>2022-10-10 12:53:52 +0000
committerLevente Polyak <anthraxx@archlinux.org>2022-10-11 20:25:08 +0200
commit5d02c6df7f9cd3a2820149886e8a32e7d8e7a566 (patch)
treed7d8113d7322266e117a06ca2ac6f722dd74c13c /lib/common.sh
parent20f89df4439c5b187314731eff2d0a0281ae1e2b (diff)
common: improve performance of find_cached_package
find_cached_package was unnecessarily looping over all packages which uses a lot of CPU and could be exceptionally slow when PKGDEST contains a lot of packages. Fix this by adding the target pkgname, pkgver and arch to the glob and only process potential candidates.
Diffstat (limited to 'lib/common.sh')
-rw-r--r--lib/common.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/common.sh b/lib/common.sh
index 56e49e6..4ebee4e 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -146,7 +146,7 @@ find_cached_package() {
[[ -d $dir ]] || continue
shopt -s extglob nullglob
- mapfile -t packages < <(printf "%s\n" "$dir"/*.pkg.tar?(.!(sig|*.*)))
+ mapfile -t packages < <(printf "%s\n" "$dir"/${targetname}-${targetver}-*${targetarch}.pkg.tar?(.!(sig|*.*)))
shopt -u extglob nullglob
for pkg in "${packages[@]}"; do