code checking for locked pages into a new "lockedit" plugin. Both are
[ikiwiki.git] / IkiWiki / Render.pm
index dcd107b815172d86031d7cce3fc15a9d16544099..2ad80ced3354457cb4e79c217e36be37f0f52b90 100644 (file)
@@ -195,10 +195,25 @@ sub render ($) { #{{{
                $oldpagemtime{$page}=time;
        }
        else {
-               my $content=readfile($srcfile, 1);
+               my $srcfd=readfile($srcfile, 1, 1);
                delete $depends{$file};
                will_render($file, $file, 1);
-               writefile($file, $config{destdir}, $content, 1);
+               my $destfd=writefile($file, $config{destdir}, undef, 1, 1);
+               my $blksize = 16384;
+               my ($len, $buf, $written);
+               while ($len = sysread $srcfd, $buf, $blksize) {
+                       if (! defined $len) {
+                               next if $! =~ /^Interrupted/;
+                               error("failed to read $srcfile: $!");
+                       }
+                       my $offset = 0;
+                       while ($len) {
+                               defined($written = syswrite OUT, $buf, $len, $offset)
+                                       or error("failed to write $file: $!");
+                               $len -= $written;
+                               $offset += $written;
+                       }
+               }
                $oldpagemtime{$file}=time;
        }
 } #}}}