1
0
mirror of https://github.com/pi-hole/pi-hole synced 2025-03-15 16:56:06 +00:00

store & use etags

Signed-off-by: Yoshimo <yoshimo@users.noreply.github.com>
This commit is contained in:
Yoshimo 2023-05-01 11:10:21 +02:00
parent 7bc1126978
commit 4c6df42f31

View File

@ -563,8 +563,34 @@ gravity_DownloadBlocklistFromUrl() {
cmd_ext="--resolve $domain:$port:$ip"
fi
if [ -f "${piholeDir}/list.${id}.${domain}.etag" ]
then
currentetag=$(<"${piholeDir}/list.${id}.${domain}.etag")
else
currentetag=$""
fi
#echo -e "\n current Etag: " "$currentetag"
# shellcheck disable=SC2086
####httpCode=$(curl --connect-timeout ${curl_connect_timeout} -s -L ${compression} ${cmd_ext} ${heisenbergCompensator} -w "%{http_code}" -A "${agent}" "${url}" -o "${listCurlBuffer}" 2> /dev/null)
if [ -z "$currentetag" ]
then
httpCode=$(curl --connect-timeout ${curl_connect_timeout} -s -L ${compression} ${cmd_ext} ${heisenbergCompensator} -w "%{http_code}" -A "${agent}" "${url}" -o "${listCurlBuffer}" 2> /dev/null)
else
httpCode=$(curl --connect-timeout ${curl_connect_timeout} -s -L ${compression} ${cmd_ext} --header "If-None-Match: ${currentetag}" -w "%{http_code}" -A "${agent}" "${url}" -o "${listCurlBuffer}" 2> /dev/null)
fi
# shellcheck disable=SC2086
curl -sI "${url}" -L ${compression} ${cmd_ext} ${heisenbergCompensator} -A "${agent}" | sed -n 's/^etag: //Ip' > "${piholeDir}/list.${id}.${domain}.etag"
# if [ "${httpCode}" != 304 ]
# then
# echo -e "\n statuscode: " "$httpCode"
# newetag=$(<"${piholeDir}/list.${id}.${domain}.etag")
# echo -e "\n new Etag: " "$newetag"
# fi
case $url in
# Did we "download" a local file?