mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-12-25 06:10:20 +00:00
Properly detect if local file was successfully downloaded
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
164a81776e
commit
8976930e20
1 changed files with 9 additions and 3 deletions
12
gravity.sh
12
gravity.sh
|
@ -193,9 +193,10 @@ gravity_Pull() {
|
||||||
patternBuffer=$(mktemp -p "/tmp" --suffix=".phgpb")
|
patternBuffer=$(mktemp -p "/tmp" --suffix=".phgpb")
|
||||||
|
|
||||||
# Determine if $saveLocation has read permission
|
# Determine if $saveLocation has read permission
|
||||||
if [[ -r "${saveLocation}" ]]; then
|
if [[ -r "${saveLocation}" && $url != "file"* ]]; then
|
||||||
# Have curl determine if a remote file has been modified since last retrieval
|
# Have curl determine if a remote file has been modified since last retrieval
|
||||||
# Uses "Last-Modified" header, which certain web servers do not provide (e.g: raw github urls)
|
# Uses "Last-Modified" header, which certain web servers do not provide (e.g: raw github urls)
|
||||||
|
# Note: Don't do this for local files, always download them
|
||||||
heisenbergCompensator="-z ${saveLocation}"
|
heisenbergCompensator="-z ${saveLocation}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -223,7 +224,12 @@ gravity_Pull() {
|
||||||
* ) echo -e "${OVER} ${CROSS} ${str} ${httpCode}";;
|
* ) echo -e "${OVER} ${CROSS} ${str} ${httpCode}";;
|
||||||
esac;;
|
esac;;
|
||||||
# Did we "download" a local file?
|
# Did we "download" a local file?
|
||||||
"file"*) echo -e "${OVER} ${TICK} ${str} Retrieval successful"; success=true;;
|
"file"*)
|
||||||
|
if [[ -s "${patternBuffer}" ]]; then
|
||||||
|
echo -e "${OVER} ${TICK} ${str} Retrieval successful"; success=true
|
||||||
|
else
|
||||||
|
echo -e "${OVER} ${CROSS} ${str} Not found"
|
||||||
|
fi;;
|
||||||
* ) echo -e "${OVER} ${CROSS} ${str} ${url} ${httpCode}";;
|
* ) echo -e "${OVER} ${CROSS} ${str} ${url} ${httpCode}";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -237,7 +243,7 @@ gravity_Pull() {
|
||||||
gravity_ParseFileIntoDomains "${patternBuffer}" "${saveLocation}"
|
gravity_ParseFileIntoDomains "${patternBuffer}" "${saveLocation}"
|
||||||
else
|
else
|
||||||
# Fall back to previously cached list if $patternBuffer is empty
|
# Fall back to previously cached list if $patternBuffer is empty
|
||||||
echo -e " ${INFO} ${COL_LIGHT_GREEN}Using previously cached list${COL_NC}"
|
echo -e " ${INFO} Received empty file: ${COL_LIGHT_GREEN}using previously cached list${COL_NC}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# Determine if cached list has read permission
|
# Determine if cached list has read permission
|
||||||
|
|
Loading…
Reference in a new issue