summaryrefslogtreecommitdiff
path: root/checkVersions
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-01-03 09:03:52 +0100
committerErich Eckner <git@eckner.net>2019-01-03 09:03:52 +0100
commitfee88885c2824416707e676b3a2d93d847bf5f24 (patch)
tree70a7e595c19e3ee1ef8642fec4cbc66332fef2cf /checkVersions
parent878e361fff36595fe3e29372f89f98f8ebcff501 (diff)
downloadarchlinuxewe-fee88885c2824416707e676b3a2d93d847bf5f24.tar.xz
checkVersions: cache curl queries
Diffstat (limited to 'checkVersions')
-rwxr-xr-xcheckVersions25
1 files changed, 24 insertions, 1 deletions
diff --git a/checkVersions b/checkVersions
index dd534c677..794286232 100755
--- a/checkVersions
+++ b/checkVersions
@@ -12,13 +12,36 @@ usage() {
curl_it() {
local source="$1"
+ local cache_file
+ cache_file=$(
+ {
+ printf '%s\n' "$1"
+ printf '%s\n' "$@" | \
+ sort -u
+ } | \
+ sha512sum | \
+ awk '{print $1}'
+ )
shift
- curl --compressed --connect-timeout 10 -s "$@" "${source}"
+ cache_file="${curl_cache}/${cache_file}"
+ if [ -s "${cache_file}" ] && \
+ [ $(stat -c%Y "${cache_file}") -gt $(($(date +%s)-300)) ]; then
+ cat "${cache_file}"
+ return
+ fi
+ curl --compressed --connect-timeout 10 -s "$@" "${source}" \
+ > "${cache_file}"
+ if [ ! -s "${cache_file}" ]; then
+ curl --compressed --connect-timeout 10 -s -x socks5://127.0.0.1:9050 "$@" "${source}" \
+ > "${cache_file}"
+ fi
+ cat "${cache_file}"
}
me="$(readlink -f $0)"
cd $(dirname "${me}")
versionenDatei="/var/cache/$(basename "$(dirname "${me}")")/lastVersions"
+curl_cache="/var/cache/$(basename "$(dirname "${me}")")/curl-cache"
jobs=0
maschinenlesbar=false
force=false