From d23786cb6c5b3320d4b0c45df3424acea51e90ad Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 11 Jul 2011 21:35:46 -0400 Subject: attachment: Bugfix to create directory when moving attachment out of holding area. --- IkiWiki/Plugin/attachment.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index d8e2f6271..fd4096edf 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -273,11 +273,13 @@ sub attachments_save { my $dir=attachment_holding_location($form->field('page')); foreach my $filename (glob("$dir/*")) { next unless -f $filename; - my $dest=$config{srcdir}."/". + my $destdir=$config{srcdir}."/". linkpage(IkiWiki::possibly_foolish_untaint( - attachment_location($form->field('page')))). - IkiWiki::basename($filename); + attachment_location($form->field('page')))); + my $destfile=IkiWiki::basename($filename); + my $dest=$destdir.$destfile; unlink($dest); + IkiWiki::prep_writefile($destfile, $destdir); rename($filename, $dest); push @attachments, $dest; } -- cgit v1.2.3 From aef85a247a4a9fbfe61225324f5efb462de52a6a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 15 Jul 2011 18:41:04 -0400 Subject: remove debug --- IkiWiki/Plugin/remove.pm | 1 - 1 file changed, 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index b94447020..a58f87fb3 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -123,7 +123,6 @@ sub removal_confirm ($$@) { if (IkiWiki::Plugin::attachment->can("is_held_attachment")) { my $f=IkiWiki::Plugin::attachment::is_held_attachment($page); if (defined $f) { - print STDERR "!! remove $f\n"; require IkiWiki::Render; IkiWiki::prune($f); } -- cgit v1.2.3 From 87db6fbb79d3141248831db78b0683222942aaec Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 15 Jul 2011 18:42:00 -0400 Subject: only check for held attachments when operating on an attachment --- IkiWiki/Plugin/remove.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index a58f87fb3..14ac01c9b 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -120,7 +120,7 @@ sub removal_confirm ($$@) { # Special case for unsaved attachments. foreach my $page (@pages) { - if (IkiWiki::Plugin::attachment->can("is_held_attachment")) { + if ($attachment && IkiWiki::Plugin::attachment->can("is_held_attachment")) { my $f=IkiWiki::Plugin::attachment::is_held_attachment($page); if (defined $f) { require IkiWiki::Render; -- cgit v1.2.3 From 4cd2efef8c6aed3adff9bebfcd3db0c0b5c0d272 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 15 Jul 2011 18:46:16 -0400 Subject: fix two recently introduced bugs in rename * rename: Fix logic error that broke renaming pages when the attachment plugin was disabled. * rename: Fix logic error that bypassed the usual pagespec checks. --- IkiWiki/Plugin/rename.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm index aa1081756..8e32d41ae 100644 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@ -184,7 +184,7 @@ sub rename_start ($$$$) { my $held=$attachment && IkiWiki::Plugin::attachment->can("is_held_attachment") && IkiWiki::Plugin::attachment::is_held_attachment($page); - if (! defined $held) { + if (! $held) { check_canrename($page, $pagesources{$page}, undef, undef, $q, $session); } @@ -322,7 +322,7 @@ sub sessioncgi ($$) { my $held=$q->param("attachment") && IkiWiki::Plugin::attachment->can("is_held_attachment") && IkiWiki::Plugin::attachment::is_held_attachment($src); - if (defined $held) { + if ($held) { rename($held, IkiWiki::Plugin::attachment::attachment_holding_location($dest)); postrename($session, $src, $dest, $q->param("attachment")) unless defined $srcfile; -- cgit v1.2.3