From: Frank Lichtenheld Date: Fri, 8 Aug 2008 19:44:55 +0000 (-0300) Subject: Packages::Dispatcher: Fix date logics again X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=03fd65fd5acb38809b66bf2e5af864395e2f6588;p=deb%2Fpackages.git Packages::Dispatcher: Fix date logics again * Due to a inverted test Last-Modified was always set to "now" * Do not allow expires to be in the past --- diff --git a/lib/Packages/Dispatcher.pm b/lib/Packages/Dispatcher.pm index e8f0679..d8b750c 100755 --- a/lib/Packages/Dispatcher.pm +++ b/lib/Packages/Dispatcher.pm @@ -94,9 +94,11 @@ sub do_dispatch { &Packages::DB::init(); my $last_modified = $Packages::DB::db_read_time; my $now = time; + my $expires = $last_modified + (12*3600); + $expires = $now + 3600 if $expires < $now; # allow some fudge, since the db mod time is not the end of # the cron job - $last_modified = $now if $last_modified - $now < 3600; + $last_modified = $now if $now - $last_modified < 3600; if ($input->http('If-Modified-Since') and (my $modtime = str2time($input->http('If-Modified-Since'), 'UTC'))) { @@ -351,7 +353,7 @@ sub do_dispatch { -last_modified => strftime("%a, %d %b %Y %T %z", localtime($last_modified)), -expires => strftime("%a, %d %b %Y %T %z", - localtime($last_modified + (12*3600))), + localtime($expires)), ); #use Data::Dumper; #print '
'.Dumper(\%ENV, \%page_content, get_all_messages()).'
';