From: Joey Hess Date: Tue, 14 Jun 2011 19:30:19 +0000 (-0400) Subject: more generic interface X-Git-Tag: 3.20110707~60^2~20 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/d4254c7f97cacffe500c3a9b6c1d887ebd3687fb more generic interface --- diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index f97ab45a4..f8a3a68c6 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -160,18 +160,16 @@ sub attachment_holding_dir { IkiWiki::possibly_foolish_untaint(linkpage($page)); } -sub remove_held_attachment { +sub is_held_attachment { my $attachment=shift; my $f=attachment_holding_dir($attachment); $f=~s/\/$//; if (-f $f) { - require IkiWiki::Render; - IkiWiki::prune($f); - return 1; + return $f } else { - return 0; + return undef; } } diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index 5e5b83349..e6f7e1dbd 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -120,8 +120,15 @@ sub removal_confirm ($$@) { # Special case for unsaved attachments. @pages=grep { - ! (IkiWiki::Plugin::attachment->can("remove_held_attachment") && - IkiWiki::Plugin::attachment::remove_held_attachment($_)) + if (IkiWiki::Plugin::attachment->can("is_held_attachment")) { + my $f=IkiWiki::Plugin::attachment::is_held_attachment($_); + if (defined $f) { + require IkiWiki::Render; + IkiWiki::prune($f); + 0; + } + } + 1; } @pages; return unless @pages;