diff options
author | Erich Eckner <git@eckner.net> | 2019-01-03 09:03:52 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-01-03 09:03:52 +0100 |
commit | fee88885c2824416707e676b3a2d93d847bf5f24 (patch) | |
tree | 70a7e595c19e3ee1ef8642fec4cbc66332fef2cf /checkVersions | |
parent | 878e361fff36595fe3e29372f89f98f8ebcff501 (diff) | |
download | archlinuxewe-fee88885c2824416707e676b3a2d93d847bf5f24.tar.xz |
checkVersions: cache curl queries
Diffstat (limited to 'checkVersions')
-rwxr-xr-x | checkVersions | 25 |
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 |