]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/remove.pm
prune: do not prune beyond an optional base directory, and add a test
[ikiwiki.git] / IkiWiki / Plugin / remove.pm
index 5e5b83349b63dd6b5790023dcbd0b302bffa8c8d..3e9f9b82f3326872d3155678570d34785974e1c2 100644 (file)
@@ -119,10 +119,16 @@ sub removal_confirm ($$@) {
        my @pages=@_;
                
        # Special case for unsaved attachments.
-       @pages=grep {
-               ! (IkiWiki::Plugin::attachment->can("remove_held_attachment") &&
-                  IkiWiki::Plugin::attachment::remove_held_attachment($_))
-       } @pages;
+       foreach my $page (@pages) {
+               if ($attachment && IkiWiki::Plugin::attachment->can("is_held_attachment")) {
+                       my $f=IkiWiki::Plugin::attachment::is_held_attachment($page);
+                       if (defined $f) {
+                               require IkiWiki::Render;
+                               IkiWiki::prune($f, "$config{wikistatedir}/attachments");
+                       }
+               }
+       }
+       @pages=grep { exists $pagesources{$_} } @pages;
        return unless @pages;
 
        foreach my $page (@pages) {
@@ -229,7 +235,7 @@ sub sessioncgi ($$) {
                        }
                        else {
                                foreach my $file (@files) {
-                                       IkiWiki::prune("$config{srcdir}/$file");
+                                       IkiWiki::prune("$config{srcdir}/$file", $config{srcdir});
                                }
                        }
                        IkiWiki::refresh();