]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Render.pm
web commit by intrigeri: bug submission
[git.ikiwiki.info.git] / IkiWiki / Render.pm
index 272eb239a08a4ea2d2bb2683c01a3bee6b1bfa03..c241fd40b5beb7abff5901246930d978cb9476b5 100644 (file)
@@ -80,7 +80,7 @@ sub genpage ($$) { #{{{
        my $actions=0;
 
        if (length $config{cgiurl}) {
-               $template->param(editurl => cgiurl(do => "edit", page => pagetitle($page, 1)));
+               $template->param(editurl => cgiurl(do => "edit", page => $page));
                $template->param(prefsurl => cgiurl(do => "prefs"));
                $actions++;
        }
@@ -180,6 +180,30 @@ sub scan ($) { #{{{
        }
 } #}}}
 
+sub fast_file_copy (@) { #{{{
+       my $srcfile=shift;
+       my $destfile=shift;
+       my $srcfd=shift;
+       my $destfd=shift;
+       my $cleanup=shift;
+
+       my $blksize = 16384;
+       my ($len, $buf, $written);
+       while ($len = sysread $srcfd, $buf, $blksize) {
+               if (! defined $len) {
+                       next if $! =~ /^Interrupted/;
+                       error("failed to read $srcfile: $!", $cleanup);
+               }
+               my $offset = 0;
+               while ($len) {
+                       defined($written = syswrite $destfd, $buf, $len, $offset)
+                               or error("failed to write $destfile: $!", $cleanup);
+                       $len -= $written;
+                       $offset += $written;
+               }
+       }
+}
+
 sub render ($) { #{{{
        my $file=shift;
        
@@ -215,24 +239,7 @@ sub render ($) { #{{{
                
                my $srcfd=readfile($srcfile, 1, 1);
                writefile($file, $config{destdir}, undef, 1, sub {
-                       my $destfd=shift;
-                       my $cleanup=shift;
-
-                       my $blksize = 16384;
-                       my ($len, $buf, $written);
-                       while ($len = sysread $srcfd, $buf, $blksize) {
-                               if (! defined $len) {
-                                       next if $! =~ /^Interrupted/;
-                                       error("failed to read $srcfile: $!", $cleanup);
-                               }
-                               my $offset = 0;
-                               while ($len) {
-                                       defined($written = syswrite $destfd, $buf, $len, $offset)
-                                               or error("failed to write $file: $!", $cleanup);
-                                       $len -= $written;
-                                       $offset += $written;
-                               }
-                       }
+                       fast_file_copy($srcfile, $file, $srcfd, @_);
                });
        }
 } #}}}