X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/54f600af14bf6dc067ffc30ec6f22d517001fe99..c321f5406b29e29b6ff61ab9e291a24d68e9d824:/IkiWiki/Plugin/autoindex.pm diff --git a/IkiWiki/Plugin/autoindex.pm b/IkiWiki/Plugin/autoindex.pm index c71d73349..11595e217 100644 --- a/IkiWiki/Plugin/autoindex.pm +++ b/IkiWiki/Plugin/autoindex.pm @@ -33,21 +33,26 @@ sub genindex ($) { sub refresh () { eval q{use File::Find}; error($@) if $@; + eval q{use Cwd}; + error($@) if $@; + my $origdir=getcwd(); my (%pages, %dirs); foreach my $dir ($config{srcdir}, @{$config{underlaydirs}}, $config{underlaydir}) { + chdir($dir) || next; + find({ no_chdir => 1, wanted => sub { - $_=decode_utf8($_); - if (IkiWiki::file_pruned($_, $dir)) { + my $file=decode_utf8($_); + $file=~s/^\.\/?//; + return unless length $file; + if (IkiWiki::file_pruned($file)) { $File::Find::prune=1; } elsif (! -l $_) { - my ($f)=/$config{wiki_file_regexp}/; # untaint + my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint return unless defined $f; - $f=~s/^\Q$dir\E\/?//; - return unless length $f; return if $f =~ /\._([^.]+)$/; # skip internal page if (! -d _) { $pages{pagename($f)}=1; @@ -57,7 +62,9 @@ sub refresh () { } } } - }, $dir); + }, '.'); + + chdir($origdir) || die "chdir $origdir: $!"; } my %deleted; @@ -110,8 +117,8 @@ sub refresh () { } if ($config{rcs}) { IkiWiki::rcs_commit_staged( - gettext("automatic index generation"), - undef, undef); + message => gettext("automatic index generation"), + ); IkiWiki::enable_commit_hook(); } }