summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-09-23 17:04:01 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-09-23 17:04:01 -0400
commit9b576023945bfc603ebf377e2048ecdd1a23582c (patch)
tree5d8db496f5a10f519631e329d7773b4731df94d7
parent9cbc46f49ab32b12358407647f2a3583ce43789a (diff)
factor out do_rename
-rw-r--r--IkiWiki/Plugin/rename.pm45
1 files changed, 29 insertions, 16 deletions
diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm
index e5dfa4b01..fcfdee424 100644
--- a/IkiWiki/Plugin/rename.pm
+++ b/IkiWiki/Plugin/rename.pm
@@ -273,23 +273,13 @@ sub sessioncgi ($$) { #{{{
check_canrename($src, $srcfile, $dest, $destfile,
$q, $session, $q->param("attachment"));
- # Ensures that the dest directory exists and is ok.
- IkiWiki::prep_writefile($destfile, $config{srcdir});
-
- # Do rename, update other pages, and refresh site.
- IkiWiki::disable_commit_hook() if $config{rcs};
+ # Begin renaming process, which will end with a
+ # wiki refresh.
require IkiWiki::Render;
- if ($config{rcs}) {
- IkiWiki::rcs_rename($srcfile, $destfile);
- IkiWiki::rcs_commit_staged(
- sprintf(gettext("rename %s to %s"), $srcfile, $destfile),
- $session->param("name"), $ENV{REMOTE_ADDR});
- }
- else {
- if (! rename("$config{srcdir}/$srcfile", "$config{srcdir}/$destfile")) {
- error("rename: $!");
- }
- }
+ IkiWiki::disable_commit_hook() if $config{rcs};
+
+ do_rename($srcfile, $destfile, $session);
+
my @fixedlinks;
if ($src ne $dest) {
foreach my $page (keys %links) {
@@ -321,6 +311,8 @@ sub sessioncgi ($$) { #{{{
}
}
}
+
+ # End renaming process and refresh wiki.
if ($config{rcs}) {
IkiWiki::enable_commit_hook();
IkiWiki::rcs_update();
@@ -394,5 +386,26 @@ sub renamepage_hook ($$$$) { #{{{
return $content;
}# }}}
+
+sub do_rename ($$$) { #{{{
+ my $srcfile=shift;
+ my $destfile=shift;
+ my $session=shift;
+
+ # Actual file rename happens here.
+ # First, ensure that the dest directory exists and is ok.
+ IkiWiki::prep_writefile($destfile, $config{srcdir});
+ if ($config{rcs}) {
+ IkiWiki::rcs_rename($srcfile, $destfile);
+ IkiWiki::rcs_commit_staged(
+ sprintf(gettext("rename %s to %s"), $srcfile, $destfile),
+ $session->param("name"), $ENV{REMOTE_ADDR});
+ }
+ else {
+ if (! rename("$config{srcdir}/$srcfile", "$config{srcdir}/$destfile")) {
+ error("rename: $!");
+ }
+ }
+} # }}}
1