Check for existence off srcfile in add_autofile
authorDavid Riebenbauer <davrieb@liegesta.at>
Wed, 3 Feb 2010 03:29:10 +0000 (04:29 +0100)
committerDavid Riebenbauer <davrieb@liegesta.at>
Sat, 3 Apr 2010 20:20:48 +0000 (22:20 +0200)
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
IkiWiki/Plugin/tag.pm

index 90e623330af4d760a9f941f14d04cf61b415b4c8..56c491339fec4690a6cf720e339aca8dac527934 100644 (file)
@@ -1897,9 +1897,14 @@ sub add_link ($$) {
 }
 
 sub add_autofile ($) {
 }
 
 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;
        }
 }
                push @autofiles, $file;
        }
 }
index c0b7feb23ac7c34fdd0e2ebb1ba405c97005e644..c6c99ae45cd008469b9918af315c2a2b4ffda132 100644 (file)
@@ -71,15 +71,14 @@ sub gentag ($) {
        if (defined $config{tag_autocreate} && $config{tag_autocreate}) {
                my $tagfile = newpagefile(tagpage($tag), $config{default_pageext});
                $tagfile=~s/^\///;
        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);
 
                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");
        }
 }
 
        }
 }