From 341038e8f2e5b2338d3e8df698ea90a308b6c525 Mon Sep 17 00:00:00 2001 From: Andreas Waidler Date: Sun, 26 Jun 2011 13:18:33 +0200 Subject: [PATCH] Items will only be overwritten if date > mtime. --- TODO | 34 ++++++++++------------------------ src/fs.c | 4 ++++ tests_usr/item_update_ascending.rss | 16 ++++++++++++++++ tests_usr/item_update_ascending.sh | 24 ++++++++++++++++++++++++ tests_usr/item_update_descending.rss | 16 ++++++++++++++++ tests_usr/item_update_descending.sh | 24 ++++++++++++++++++++++++ tests_usr/tests | 2 ++ 7 files changed, 96 insertions(+), 24 deletions(-) rewrite TODO (60%) create mode 100644 tests_usr/item_update_ascending.rss create mode 100755 tests_usr/item_update_ascending.sh create mode 100644 tests_usr/item_update_descending.rss create mode 100755 tests_usr/item_update_descending.sh diff --git a/TODO b/TODO dissimilarity index 60% index beadd48..93c745b 100644 --- a/TODO +++ b/TODO @@ -1,24 +1,10 @@ -* Since every item that is fetched (can) increase the feed - date when that feed is flushed, a subsequent run will only - write and thus overwrite the item if it has a newer - pubDate. - However, if one item occurrs several times in the same feed, - only the most recent one should be written. - - IOW: date conflicts can only happen within a single run. - but we have no possibility to check items of a single - run. so check all that are stored. - - Thus, only (over)write items if date > old date. - - tests: item_duplicates: asc/desc feeds, check whether - stored item has contents/date/etc of most recent one. -* Make directories/items read-only. -* no date -> current date. write all items with date >= - feed date. -* check whether dates are handled properly (timezones!) -* fix remaining bugs (see README) -* support lastBuildDate and pubDate for channels -* replace assertions by proper error handling -* clean state after a tag level is left, so we can pipe - multiple streams, one after another, into one instance. +* test: item_order_ascending.sh -> sample_asc.sh +* Make directories/items read-only. +* no date -> current date. write all items with date >= + feed date. +* check whether dates are handled properly (timezones!) +* fix remaining bugs (see README) +* support lastBuildDate and pubDate for channels +* replace assertions by proper error handling +* clean state after a tag level is left, so we can pipe + multiple streams, one after another, into one instance. diff --git a/src/fs.c b/src/fs.c index cf3332a..7fae1ac 100644 --- a/src/fs.c +++ b/src/fs.c @@ -156,6 +156,7 @@ void fs_set(const char* name, const char* value) void item_flush() { struct timeval times[2]; + struct stat st; char buf[FILE_NAME_LENGTH + 1] = { 0 }; const char* name_src; assert(feed_title[0]); @@ -178,6 +179,9 @@ void item_flush() if (mkdir(buf, 0755)) { assert(errno == EEXIST); + + stat(buf, &st); + if (st.st_mtime >= item_date) return; } assert(chdir(buf) == 0); diff --git a/tests_usr/item_update_ascending.rss b/tests_usr/item_update_ascending.rss new file mode 100644 index 0000000..07aa6b6 --- /dev/null +++ b/tests_usr/item_update_ascending.rss @@ -0,0 +1,16 @@ + + + + feed + + item + first + Fri, 02 Apr 2010 12:10:00 +0200 + + + item + second + Sat, 02 Oct 2010 22:43:23 +0200 + + + diff --git a/tests_usr/item_update_ascending.sh b/tests_usr/item_update_ascending.sh new file mode 100755 index 0000000..8f1d713 --- /dev/null +++ b/tests_usr/item_update_ascending.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# Copyright (C) 2011 Andreas Waidler +# +# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +# +# 0. You just DO WHAT THE FUCK YOU WANT TO. + +. ./libtests.sh + +feed_exists() { assert_exists feed; } +feed_date() { assert_date feed 1286052203; } +item_exists() { assert_exists feed/item; } +item_date() { assert_date feed/item 1286052203; } +item_desc() { assert_value feed/item desc second; } + + +echo "Running agg on feed containing updated item (ascending order)..." +agg_run item_update_ascending.rss +t feed_exists +t feed_date +t item_exists +t item_desc +t item_date diff --git a/tests_usr/item_update_descending.rss b/tests_usr/item_update_descending.rss new file mode 100644 index 0000000..a186d9b --- /dev/null +++ b/tests_usr/item_update_descending.rss @@ -0,0 +1,16 @@ + + + + feed + + item + second + Sat, 02 Oct 2010 22:43:23 +0200 + + + item + first + Fri, 02 Apr 2010 12:10:00 +0200 + + + diff --git a/tests_usr/item_update_descending.sh b/tests_usr/item_update_descending.sh new file mode 100755 index 0000000..cf924b5 --- /dev/null +++ b/tests_usr/item_update_descending.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# Copyright (C) 2011 Andreas Waidler +# +# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +# +# 0. You just DO WHAT THE FUCK YOU WANT TO. + +. ./libtests.sh + +feed_exists() { assert_exists feed; } +feed_date() { assert_date feed 1286052203; } +item_exists() { assert_exists feed/item; } +item_date() { assert_date feed/item 1286052203; } +item_desc() { assert_value feed/item desc second; } + + +echo "Running agg on feed containing updated item (descending order)..." +agg_run item_update_descending.rss +t feed_exists +t feed_date +t item_exists +t item_desc +t item_date diff --git a/tests_usr/tests b/tests_usr/tests index 7e671f8..1e3c7b1 100755 --- a/tests_usr/tests +++ b/tests_usr/tests @@ -23,6 +23,8 @@ simple_t.sh simple_d.sh sample.sh item_order_ascending.sh +item_update_descending.sh +item_update_ascending.sh long_item_title.sh feed_broken.sh item_broken.sh -- 2.11.4.GIT