commit a94f19744a2b62b021fcd3741ec2e4d5316ed49a
parent 7270aee2452804631741c971d3b4bc6d52ca72a6
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Tue, 12 Jan 2021 01:02:37 +0100
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.
Diffstat:
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git 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