sogrep: fail if links database cannot be retrieved

If the links database (for some reason) does not exist on the mirror,
curl will save the html 404 page as ${repo}.links.tar.gz in the cache,
and sogrep will later fail with a decompression error from bsdtar.

This patch adds -f to curl so it doesn't save the error page, and exit
after displaying an error in such case.

Fixes !88

Signed-off-by: Haochen Tong <i@hexchain.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
Haochen Tong 2022-02-02 21:51:59 +08:00 committed by Levente Polyak
parent 74164e348b
commit 82cb6756aa
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
1 changed files with 5 additions and 2 deletions

View File

@ -36,8 +36,11 @@ recache() {
local dbpath=${SOCACHE_DIR}/${arch}/${repo}.links.tar.gz
mkdir -p "${dbpath%/*}"
(( VERBOSE )) && echo "Fetching ${repo}.links.tar.gz..."
curl -LR "${verbosity}" -o "${dbpath}" -z "${dbpath}" \
"${SOLINKS_MIRROR}/${repo}/os/${arch}/${repo}.links.tar.gz"
if ! curl -fLR "${verbosity}" -o "${dbpath}" -z "${dbpath}" \
"${SOLINKS_MIRROR}/${repo}/os/${arch}/${repo}.links.tar.gz"; then
echo "error: failed to download links database for repo ${repo}"
exit 1
fi
done
done
}