summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/aggregate.pm
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2010-07-11 10:46:18 +0200
committerintrigeri <intrigeri@boum.org>2010-07-11 10:46:18 +0200
commitc99d26030e6ddd7a21932e98e40a8df7d896886d (patch)
tree26056e3e2a5c7c81ebe7baf243a0bb4ae765e76e /IkiWiki/Plugin/aggregate.pm
parentc9b1a4dd7d826b5e8e2d0a757ba5ecbba8d832b2 (diff)
parent1bb9157f2ab94b8306e1e2fb1a5b3ac9bbfe5772 (diff)
Merge remote branch 'upstream/master' into prv/po
Conflicts: IkiWiki/Plugin/po.pm doc/plugins/po.mdwn
Diffstat (limited to 'IkiWiki/Plugin/aggregate.pm')
-rw-r--r--IkiWiki/Plugin/aggregate.pm18
1 files changed, 16 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm
index 5a9eb433d..7789c4c2a 100644
--- a/IkiWiki/Plugin/aggregate.pm
+++ b/IkiWiki/Plugin/aggregate.pm
@@ -298,7 +298,7 @@ sub loadstate () {
return if $state_loaded;
$state_loaded=1;
if (-e "$config{wikistatedir}/aggregate") {
- open(IN, "$config{wikistatedir}/aggregate") ||
+ open(IN, "<", "$config{wikistatedir}/aggregate") ||
die "$config{wikistatedir}/aggregate: $!";
while (<IN>) {
$_=IkiWiki::possibly_foolish_untaint($_);
@@ -335,7 +335,7 @@ sub savestate () {
garbage_collect();
my $newfile="$config{wikistatedir}/aggregate.new";
my $cleanup = sub { unlink($newfile) };
- open (OUT, ">$newfile") || error("open $newfile: $!", $cleanup);
+ open (OUT, ">", $newfile) || error("open $newfile: $!", $cleanup);
foreach my $data (values %feeds, values %guids) {
my @line;
foreach my $field (keys %$data) {
@@ -356,6 +356,20 @@ sub savestate () {
close OUT || error("save $newfile: $!", $cleanup);
rename($newfile, "$config{wikistatedir}/aggregate") ||
error("rename $newfile: $!", $cleanup);
+
+ my $timestamp=undef;
+ foreach my $feed (keys %feeds) {
+ my $t=$feeds{$feed}->{lastupdate}+$feeds{$feed}->{updateinterval};
+ if (! defined $timestamp || $timestamp > $t) {
+ $timestamp=$t;
+ }
+ }
+ $newfile=~s/\.new$/time/;
+ open (OUT, ">", $newfile) || error("open $newfile: $!", $cleanup);
+ if (defined $timestamp) {
+ print OUT $timestamp."\n";
+ }
+ close OUT || error("save $newfile: $!", $cleanup);
}
sub garbage_collect () {