From a94d9664c1ba82ed1f0f2b9c22de9ee4138bf3af Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 24 Jul 2009 17:48:42 +0100 Subject: [PATCH] Actually compress marketdata.gz (!) --- pctb/commod-results-processor | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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), ] }; -- 2.30.2