got rid of the postrefresh hook after all
authorJoey Hess <joey@gnu.kitenet.net>
Fri, 11 Sep 2009 22:29:56 +0000 (18:29 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Fri, 11 Sep 2009 22:29:56 +0000 (18:29 -0400)
Instead, use the change and delete hooks, and launch rsync if either hook
is called.

IkiWiki/Plugin/rsync.pm
IkiWiki/Render.pm

index f14989ff835ac929675666ee91cd3a5d68f8261b..45bff19bd357b6e1a80f239d983f54085c5cec92 100644 (file)
@@ -7,7 +7,8 @@ use IkiWiki 3.00;
 
 sub import {
        hook(type => "getsetup", id => "rsync", call => \&getsetup);
-       hook(type => "postrefresh", id => "rsync", call => \&postrefresh);
+       hook(type => "change", id => "rsync", call => \&postrefresh);
+       hook(type => "delete", id => "rsync", call => \&postrefresh);
 }
 
 sub getsetup () {
@@ -25,8 +26,11 @@ sub getsetup () {
                },
 }
 
+my $ran=0;
+
 sub postrefresh () {
-       if (defined $config{rsync_command}) {
+       if (defined $config{rsync_command} && ! $ran) {
+               $ran=1;
                chdir($config{destdir}) || error("chdir: $!");
                system $config{rsync_command};
                if ($? == -1) {
index 5953b3feef93c9af06b8a491141635f3552fae82..246c2260d7748e9fe2b3522d73035564e0fb6754 100644 (file)
@@ -554,7 +554,6 @@ sub refresh () {
        if (%rendered) {
                run_hooks(change => sub { shift->(keys %rendered) });
        }
-       run_hooks(postrefresh => sub { shift->() });
 }
 
 sub commandline_render () {