]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
more generic interface
authorJoey Hess <joey@kitenet.net>
Tue, 14 Jun 2011 19:30:19 +0000 (15:30 -0400)
committerJoey Hess <joey@kitenet.net>
Tue, 14 Jun 2011 19:31:58 +0000 (15:31 -0400)
IkiWiki/Plugin/attachment.pm
IkiWiki/Plugin/remove.pm

index f97ab45a4ff562604712850801eb480cc6c293a6..f8a3a68c601c373a927ff9f175f1a00772d8f9c6 100644 (file)
@@ -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;
        }
 }
 
index 5e5b83349b63dd6b5790023dcbd0b302bffa8c8d..e6f7e1dbd1c530e47a1accccdbcd0232723d52b1 100644 (file)
@@ -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;