aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-06-14 15:30:19 -0400
committerJoey Hess <joey@kitenet.net>2011-06-14 15:31:58 -0400
commitd4254c7f97cacffe500c3a9b6c1d887ebd3687fb (patch)
treeaa5739d2719e21c198349de1d82d1deb8d8175c4
parent49e7bc253569c809ba5d4d9e52f8a38ae8c183f7 (diff)
downloadikiwiki-d4254c7f97cacffe500c3a9b6c1d887ebd3687fb.tar
ikiwiki-d4254c7f97cacffe500c3a9b6c1d887ebd3687fb.tar.gz
more generic interface
-rw-r--r--IkiWiki/Plugin/attachment.pm8
-rw-r--r--IkiWiki/Plugin/remove.pm11
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;