summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2016-01-31 15:31:17 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2016-01-31 15:31:17 +0100
commit77a603a904087dd9fd3350da029f279f076e4f4b (patch)
tree94c4db9257eacb369d44e04e6746b89830b08526
parent9f596550ca47071fe31b03e4ab27e08c60b65f71 (diff)
sfeed_update: fix issue with merging failed feeds
When fetching a feed failed and its temporary file was stored (filesize=0) it would still be merged with the (possible) old file. This updated the modification time which would be used in the next poll (If-Modified-Since). The solution is to check if the file is non-empty and only then merge, this is still not 100% fool-proof, but much better.
-rwxr-xr-xsfeed_update19
1 files changed, 11 insertions, 8 deletions
diff --git a/sfeed_update b/sfeed_update
index eafbcfe..8185345 100755
--- a/sfeed_update
+++ b/sfeed_update
@@ -78,14 +78,17 @@ feed() {
# get new data and merge with old.
sfeedfilenew="${sfeedpath}/${name}.new"
- # if file exists, merge
- if [ -e "${sfeedfile}" ]; then
- merge "${sfeedfile}" "${tmpfeedfile}" > "${sfeedfilenew}"
- # overwrite old file with updated file
- mv "${sfeedfilenew}" "${sfeedfile}"
- else
- # else just copy
- mv "${tmpfeedfile}" "${sfeedfile}"
+ # new feed data is non-empty.
+ if [ -s "${tmpfeedfile}" ]; then
+ # if file exists, merge
+ if [ -e "${sfeedfile}" ]; then
+ merge "${sfeedfile}" "${tmpfeedfile}" > "${sfeedfilenew}"
+ # overwrite old file with updated file
+ mv "${sfeedfilenew}" "${sfeedfile}"
+ else
+ # else just copy
+ mv "${tmpfeedfile}" "${sfeedfile}"
+ fi
fi) &
}