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.
This commit is contained in:
Hiltjo Posthuma 2021-01-12 01:02:37 +01:00
parent 7270aee245
commit a94f19744a
1 changed files with 4 additions and 8 deletions

View File

@ -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