aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Render.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-11-30 17:16:44 -0500
committerJoey Hess <joey@gnu.kitenet.net>2009-11-30 17:34:29 -0500
commitf1ddf4bd98821a597d8fa1532092f09d3d9b5483 (patch)
tree52661d1ef666858eecd67cbdf86dc958993c35d2 /IkiWiki/Render.pm
parentcdd9ef8d588650b19ebdf7724e25cc15bfb2b218 (diff)
downloadikiwiki-f1ddf4bd98821a597d8fa1532092f09d3d9b5483.tar
ikiwiki-f1ddf4bd98821a597d8fa1532092f09d3d9b5483.tar.gz
fix bestlink to not return just-deleted pages
bestlink was looking at whether %links existed for a page in order to tell if the page exists, but just-deleted pages still have entries in there (for reasons it may be best not to explore). So bestlink would return just-deleted pages. Instead, make bestlink use %pagesources. Also, when finding a deleted page, %pagecase was not cleared of that page. This, again, made bestlink return just-deleted pages. Now that is cleared. Fixing bestlink exposed another issue though. The backlink calculation code uses bestlink. So when a page was deleted, no backlinks to it are found, and pages that really did backlink to it were not updated, and had broken links. To fix that, the code that actually removes deleted pages had to be split out from find_del_files, so it can run a bit later. It is run just after backlinks are calculated. This way, backlink calculation still sees the deleted pages, but everything afterwards does not. However, it does not address the original bug report that started this whole thing, [[bugs/bestlink_returns_deleted_pages]]. Because there bestlink is run in the needsbuild hook. And that happens before backlink calculation, and so bestlink still returns deleted pages then. Also in the scan hook. If bestlink needs to work consistently during those hooks, a more involved fix will be needed.
Diffstat (limited to 'IkiWiki/Render.pm')
-rw-r--r--IkiWiki/Render.pm34
1 files changed, 24 insertions, 10 deletions
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index ab3a71671..dec9293ad 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -392,27 +392,39 @@ sub find_del_files ($) {
push @internal_del, $pagesources{$page};
}
else {
- debug(sprintf(gettext("removing old page %s"), $page));
push @del, $pagesources{$page};
}
$links{$page}=[];
$renderedfiles{$page}=[];
$pagemtime{$page}=0;
- foreach my $old (@{$oldrenderedfiles{$page}}) {
- prune($config{destdir}."/".$old);
- }
- delete $pagesources{$page};
- foreach my $source (keys %destsources) {
- if ($destsources{$source} eq $page) {
- delete $destsources{$source};
- }
- }
}
}
return \@del, \@internal_del;
}
+sub remove_del (@) {
+ foreach my $file (@_) {
+ my $page=pagename($file);
+ if (isinternal($page)) {
+ debug(sprintf(gettext("removing old page %s"), $page));
+ }
+
+ foreach my $old (@{$oldrenderedfiles{$page}}) {
+ prune($config{destdir}."/".$old);
+ }
+
+ foreach my $source (keys %destsources) {
+ if ($destsources{$source} eq $page) {
+ delete $destsources{$source};
+ }
+ }
+
+ delete $pagecase{lc $page};
+ delete $pagesources{$page};
+ }
+}
+
sub find_changed ($) {
my $files=shift;
my @changed;
@@ -633,6 +645,8 @@ sub refresh () {
}
calculate_links();
+
+ remove_del(@$del, @$internal_del);
foreach my $file (@$changed) {
render($file, sprintf(gettext("building %s"), $file));