diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-01-12 01:02:37 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-01-16 12:27:13 +0100 |
commit | a94f19744a2b62b021fcd3741ec2e4d5316ed49a (patch) | |
tree | 3ba3cc43d9abe346ddff7de0fa54a2d4b4f227b8 | |
parent | 7270aee2452804631741c971d3b4bc6d52ca72a6 (diff) |
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.
-rwxr-xr-x | sfeed_update | 12 |
1 files changed, 4 insertions, 8 deletions
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 |