From: Ian Jackson Date: Fri, 24 Jul 2009 16:48:42 +0000 (+0100) Subject: Actually compress marketdata.gz (!) X-Git-Tag: 3.0~44^2^2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=commitdiff_plain;h=a94d9664c1ba82ed1f0f2b9c22de9ee4138bf3af Actually compress marketdata.gz (!) --- diff --git a/pctb/commod-results-processor b/pctb/commod-results-processor index 4a70ddf..fe26f88 100755 --- a/pctb/commod-results-processor +++ b/pctb/commod-results-processor @@ -435,6 +435,24 @@ sub save_upload_html ($$) { close R or die $!; } +sub gzip ($) { + my ($raw) = @_; + my $tf= IO::File::new_tmpfile() or die $!; + print $tf $raw or die $!; + $tf->flush or die $!; + $tf->seek(0,0) or die $!; + my $child= open GZ, "-|"; defined $child or die $!; + if (!$child) { + open STDIN, "<&", $tf; + exec 'gzip'; die $!; + } + my $r; + { undef $/; $!=0; $r= ; } + defined $r or die $!; + close GZ or die "$! $?"; die $? if $?; + return $r; +} + sub main__upload () { my $ocean= $ENV{'YPPSC_OCEAN'}; die unless $ocean; my $island= $ENV{'YPPSC_ISLAND'}; die unless $island; @@ -445,7 +463,7 @@ sub main__upload () { my $content= { 'marketdata' => [ undef, "marketdata.gz", Content_Type => 'application/gzip', - Content => $o + Content => gzip($o), ] };