- # remove no longer rendered files
- foreach my $src (keys %rendered) {
- my $page=pagename($src);
- foreach my $file (@{$oldrenderedfiles{$page}}) {
- if (! grep { $_ eq $file } @{$renderedfiles{$page}}) {
- debug(sprintf(gettext("removing %s, no longer built by %s"), $file, $page));
- prune($config{destdir}."/".$file);
+ return 0;
+}
+
+sub render_backlinks ($) {
+ my $backlinkchanged=shift;
+ foreach my $link (keys %$backlinkchanged) {
+ my $linkfile=$pagesources{$link};
+ if (defined $linkfile) {
+ render($linkfile, sprintf(gettext("building %s, to update its backlinks"), $linkfile));
+ }
+ }
+}
+
+sub gen_autofile ($$$) {
+ my $autofile=shift;
+ my $pages=shift;
+ my $del=shift;
+
+ if (file_pruned($autofile)) {
+ return;
+ }
+
+ my ($file)="$config{srcdir}/$autofile" =~ /$config{wiki_file_regexp}/; # untaint
+ if (! defined $file) {
+ return;
+ }
+
+ # Remember autofiles that were tried, and never try them again later.
+ if (exists $wikistate{$autofiles{$autofile}{plugin}}{autofile}{$autofile}) {
+ return;
+ }
+ $wikistate{$autofiles{$autofile}{plugin}}{autofile}{$autofile}=1;
+
+ if (srcfile($autofile, 1) || file_pruned($autofile)) {
+ return;
+ }
+
+ if (-l $file || -d _ || -e _) {
+ return;
+ }
+
+ my $page = pagename($file);
+ if ($pages->{$page}) {
+ return;
+ }
+
+ if (grep { $_ eq $autofile } @$del) {
+ return;
+ }
+
+ $autofiles{$autofile}{generator}->();
+ $pages->{$page}=1;
+ return 1;
+}
+
+sub refresh () {
+ $phase = PHASE_SCAN;
+
+ srcdir_check();
+ run_hooks(refresh => sub { shift->() });
+ my ($files, $pages, $new, $internal_new, $del, $internal_del, $changed, $internal_changed);
+ my $want_find_changes=$config{only_committed_changes} &&
+ exists $IkiWiki::hooks{rcs}{rcs_find_changes} &&
+ exists $IkiWiki::hooks{rcs}{rcs_get_current_rev};
+ if (! $config{rebuild} && $want_find_changes && defined $IkiWiki::lastrev && length $IkiWiki::lastrev) {
+ my ($changed_raw, $del_raw);
+ ($changed_raw, $del_raw, $IkiWiki::lastrev) = $IkiWiki::hooks{rcs}{rcs_find_changes}{call}->($IkiWiki::lastrev);
+ ($files, $pages)=process_changed_files($changed_raw, $del_raw);
+ }
+ else {
+ ($files, $pages)=find_src_files();
+ }
+ if ($want_find_changes) {
+ if (! defined($IkiWiki::lastrev) || ! length $IkiWiki::lastrev) {
+ $IkiWiki::lastrev=$IkiWiki::hooks{rcs}{rcs_get_current_rev}{call}->();
+ }
+ }
+ ($new, $internal_new)=find_new_files($files);
+ ($del, $internal_del)=find_del_files($pages);
+ ($changed, $internal_changed)=find_changed($files);
+ my %existingfiles;
+ run_hooks(needsbuild => sub {
+ my $ret=shift->($changed, [@$del, @$internal_del]);
+ if (ref $ret eq 'ARRAY' && $ret != $changed) {
+ if (! %existingfiles) {
+ foreach my $f (@$files) {
+ $existingfiles{$f}=1;
+ }