From d4254c7f97cacffe500c3a9b6c1d887ebd3687fb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 14 Jun 2011 15:30:19 -0400 Subject: [PATCH] more generic interface --- IkiWiki/Plugin/attachment.pm | 8 +++----- IkiWiki/Plugin/remove.pm | 11 +++++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) 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; -- 2.26.2