From 77a603a904087dd9fd3350da029f279f076e4f4b Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sun, 31 Jan 2016 15:31:17 +0100 Subject: 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. --- sfeed_update | 19 +++++++++++-------- 1 file 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) & } -- cgit v1.2.3