From a358d74bef51dae31332ff27e897fe04834571e6 Mon Sep 17 00:00:00 2001 From: David Riebenbauer Date: Wed, 3 Feb 2010 04:29:10 +0100 Subject: [PATCH] Check for existence off srcfile in add_autofile add_autofile has to have checks, whether to create the file, anyway, so this will make things more consistent. Correcter check for the result of verify_src_file(). Cosmetic rename of a variable $addfile to $autofile. --- IkiWiki.pm | 11 ++++++++--- IkiWiki/Plugin/tag.pm | 5 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 90e623330..56c491339 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1897,9 +1897,14 @@ sub add_link ($$) { } sub add_autofile ($) { - my $addfile=shift; - my ($file,$page) = verify_src_file($addfile,$config{srcdir}); - if ($page) { + my $autofile=shift; + + if (srcfile($autofile, 1)) { + return 0; + } + + my ($file, $page) = verify_src_file("$config{srcdir}/$autofile", $config{srcdir}); + if (defined $file) { push @autofiles, $file; } } diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index c0b7feb23..c6c99ae45 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -71,15 +71,14 @@ sub gentag ($) { if (defined $config{tag_autocreate} && $config{tag_autocreate}) { my $tagfile = newpagefile(tagpage($tag), $config{default_pageext}); $tagfile=~s/^\///; - return if (srcfile($tagfile,1)); + + return if (! add_autofile($tagfile)); debug(sprintf(gettext("creating tag page %s"), $tag)); my $template=template("autotag.tmpl"); $template->param(tag => $tag); writefile($tagfile, $config{srcdir}, $template->output); - - add_autofile("$config{srcdir}/$tagfile"); } } -- 2.32.0.93.g670b81a890