diff options
Diffstat (limited to 'IkiWiki/Render.pm')
-rw-r--r-- | IkiWiki/Render.pm | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index d8bc5a9d9..cbba28251 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -198,22 +198,26 @@ sub render ($) { #{{{ my $srcfd=readfile($srcfile, 1, 1); delete $depends{$file}; will_render($file, $file, 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; + 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; + } } - } + }); $oldpagemtime{$file}=time; } } #}}} |