* Avoid unnecessary stat calls to get mtime when rendering pages, use

cached value.
* Preserve input file modification times in output files.
master
Joey Hess 2007-12-12 14:43:35 -05:00
parent c06643a435
commit 849f65a343
2 changed files with 11 additions and 6 deletions

View File

@ -64,10 +64,9 @@ sub parentlinks ($) { #{{{
return @ret; return @ret;
} #}}} } #}}}
sub genpage ($$$) { #{{{ sub genpage ($$) { #{{{
my $page=shift; my $page=shift;
my $content=shift; my $content=shift;
my $mtime=shift;
my $templatefile; my $templatefile;
run_hooks(templatefile => sub { run_hooks(templatefile => sub {
@ -129,7 +128,7 @@ sub genpage ($$$) { #{{{
content => $content, content => $content,
backlinks => $backlinks, backlinks => $backlinks,
more_backlinks => $more_backlinks, more_backlinks => $more_backlinks,
mtime => displaytime($mtime), mtime => displaytime($pagemtime{$page}),
baseurl => baseurl($page), baseurl => baseurl($page),
); );
@ -204,8 +203,9 @@ sub render ($) { #{{{
filter($page, $page, filter($page, $page,
readfile($srcfile))))); readfile($srcfile)))));
writefile(htmlpage($page), $config{destdir}, my $output=htmlpage($page);
genpage($page, $content, mtime($srcfile))); writefile($output, $config{destdir}, genpage($page, $content));
utime($pagemtime{$page}, $pagemtime{$page}, $config{destdir}."/".$output);
} }
else { else {
my $srcfd=readfile($srcfile, 1, 1); my $srcfd=readfile($srcfile, 1, 1);
@ -231,6 +231,7 @@ sub render ($) { #{{{
} }
} }
}); });
utime($pagemtime{$file}, $pagemtime{$file}, $config{destdir}."/".$file);
} }
} #}}} } #}}}
@ -485,8 +486,9 @@ sub commandline_render () { #{{{
$content=preprocess($page, $page, $content); $content=preprocess($page, $page, $content);
$content=linkify($page, $page, $content); $content=linkify($page, $page, $content);
$content=htmlize($page, $type, $content); $content=htmlize($page, $type, $content);
$pagemtime{$page}=mtime($srcfile);
print genpage($page, $content, mtime($srcfile)); print genpage($page, $content);
exit 0; exit 0;
} #}}} } #}}}

3
debian/changelog vendored
View File

@ -25,6 +25,9 @@ ikiwiki (2.16) UNRELEASED; urgency=low
I believe this is a safe change, since only passwordauth uses this hook. I believe this is a safe change, since only passwordauth uses this hook.
(If some other plugin already used it, it would have broken passwordauth!) (If some other plugin already used it, it would have broken passwordauth!)
* Ensure that web edited pages always end in a newline. * Ensure that web edited pages always end in a newline.
* Avoid unnecessary stat calls to get mtime when rendering pages, use
cached value.
* Preserve input file modification times in output files.
-- Joey Hess <joeyh@debian.org> Mon, 03 Dec 2007 14:47:36 -0500 -- Joey Hess <joeyh@debian.org> Mon, 03 Dec 2007 14:47:36 -0500