From a94f19744a2b62b021fcd3741ec2e4d5316ed49a Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Tue, 12 Jan 2021 01:02:37 +0100 Subject: sfeed_update: improve consistency of feed creation and merging - Improve feed creation with empty results and new feed files. Always make sure the file is created even when it is new and there are also no items (after filtering). - Consistency: always use the same feed file for merging. Do not use "/dev/null" when it is a new file. This works using sort, but is ugly when the merge() function is overridden and does something else. It should be the feed file always. --- sfeed_update | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'sfeed_update') diff --git a/sfeed_update b/sfeed_update index d7c41da..c2fd06d 100755 --- a/sfeed_update +++ b/sfeed_update @@ -98,6 +98,9 @@ feed() { sfeedfile="${sfeedpath}/${filename}" tmpfeedfile="${sfeedtmpdir}/${filename}" + # if file does not exist yet create it. + [ -e "${sfeedfile}" ] || touch "${sfeedfile}" 2>/dev/null + if ! fetch "${name}" "${feedurl}" "${sfeedfile}" > "${tmpfeedfile}.fetch"; then log "${name}" "FAIL (FETCH)" return @@ -130,14 +133,7 @@ feed() { return fi - # if file does not exist yet "merge" with /dev/null. - if [ -e "${sfeedfile}" ]; then - oldfile="${sfeedfile}" - else - oldfile="/dev/null" - fi - - if ! merge "${name}" "${oldfile}" "${tmpfeedfile}.filter" > "${tmpfeedfile}.merge"; then + if ! merge "${name}" "${sfeedfile}" "${tmpfeedfile}.filter" > "${tmpfeedfile}.merge"; then log "${name}" "FAIL (MERGE)" return fi -- cgit v1.2.3