sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit 742ed57ac88f52434f966a0b44dc8bdd9dd9983b
parent 8df3ab3b50d6ca61859f6c8f1d49913276a4d32d
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue, 12 Apr 2016 18:44:32 +0200

sfeed_frames: make content filename more unique: use UNIX timestamp in title

this makes sure if an item has the same title but is posted or updated at a
different time it will not overwrite the file.

Diffstat:
Msfeed_frames.c | 16+++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/sfeed_frames.c b/sfeed_frames.c @@ -144,19 +144,21 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f) line[--linelen] = '\0'; if (!parseline(line, fields)) break; - /* write content */ - if (!normalizepath(fields[FieldTitle], name, sizeof(name))) - continue; - r = snprintf(filepath, sizeof(filepath), "%s/%s.html", dirpath, name); - if (r == -1 || (size_t)r >= sizeof(filepath)) - errx(1, "snprintf: path truncation: '%s/%s.html'", dirpath, name); parsedtime = 0; strtotime(fields[FieldUnixTimestamp], &parsedtime); - if (!(tm = localtime(&parsedtime))) err(1, "localtime"); + if (!normalizepath(fields[FieldTitle], name, sizeof(name))) + continue; + + r = snprintf(filepath, sizeof(filepath), "%s/%s-%lld.html", + dirpath, name, (long long)parsedtime); + if (r == -1 || (size_t)r >= sizeof(filepath)) + errx(1, "snprintf: path truncation: '%s/%s-%lld.html'", + dirpath, name, (long long)parsedtime); + /* content file doesn't exist yet and has error? */ if ((fd = open(filepath, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1) {