Make sure deleted tag pages don't get recreated.

The reason to do this is basically a user interaction design decision.

It is achieved by adding an entry, associated to the creating plugin, to
%pagestate. To find out if files were deleted a new global hash %del_hash is
%introduced.
master
David Riebenbauer 2010-04-03 21:10:16 +02:00
parent 628a52a6c4
commit 981400177d
3 changed files with 20 additions and 6 deletions

View File

@ -14,7 +14,7 @@ use open qw{:utf8 :std};
use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
%pagestate %wikistate %renderedfiles %oldrenderedfiles
%pagesources %destsources %depends %depends_simple %hooks
%forcerebuild %loaded_plugins @autofiles};
%forcerebuild %loaded_plugins %autofiles %del_hash};
use Exporter q{import};
our @EXPORT = qw(hook debug error template htmlpage deptype
@ -1895,17 +1895,28 @@ sub add_link ($$) {
unless grep { $_ eq $link } @{$links{$page}};
}
sub add_autofile ($) {
sub add_autofile ($$) {
my $autofile=shift;
my $plugin=shift;
if (srcfile($autofile, 1)) {
return 0;
}
my ($file, $page) = verify_src_file("$config{srcdir}/$autofile", $config{srcdir});
if (defined $file) {
push @autofiles, $file;
if ((!defined $file) ||
(exists $pagestate{$page}{$plugin}{autofile_deleted})) {
return 0;
}
if (exists $del_hash{$file}) {
$pagestate{$page}{$plugin}{autofile_deleted}=1;
return 0;
}
$autofiles{$file}=$plugin;
return 1;
}
sub pagespec_translate ($) {

View File

@ -72,7 +72,7 @@ sub gentag ($) {
my $tagfile = newpagefile(tagpage($tag), $config{default_pageext});
$tagfile=~s/^\///;
return if (! add_autofile($tagfile));
return if (! add_autofile($tagfile, "tag"));
debug(sprintf(gettext("creating tag page %s"), $tag));

View File

@ -637,12 +637,14 @@ sub refresh () {
my ($changed, $internal_changed)=find_changed($files);
run_hooks(needsbuild => sub { shift->($changed) });
my $oldlink_targets=calculate_old_links($changed, $del);
%del_hash = map { $_ => 1 } @{$del};
foreach my $file (@$changed) {
scan($file);
}
while (my $autofile = shift (@autofiles)) {
while (my $autofile = shift @{[keys %autofiles]}) {
my $plugin=$autofiles{$autofile};
my $page=pagename($autofile);
if ($pages->{$page}) {
debug(sprintf(gettext("%s has multiple possible source pages"), $page));
@ -654,6 +656,7 @@ sub refresh () {
push @{$changed}, $autofile if find_changed([$autofile]);
scan($autofile);
delete $autofiles{$autofile};
}
calculate_links();