From 2e3899ed2748802b5452dab7f9e10743e2a160b8 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 12 Aug 2015 12:22:14 +0200 Subject: [PATCH] Don't set Expires header for logs of unfinished builds/steps --- src/lib/Hydra/Controller/Build.pm | 10 +++++++--- src/lib/Hydra/View/NixLog.pm | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/Hydra/Controller/Build.pm b/src/lib/Hydra/Controller/Build.pm index c86d0be4..0ab0832e 100644 --- a/src/lib/Hydra/Controller/Build.pm +++ b/src/lib/Hydra/Controller/Build.pm @@ -119,18 +119,21 @@ sub view_nixlog : Chained('buildChain') PathPart('nixlog') { $c->stash->{step} = $step; - showLog($c, $mode, $step->drvpath, map { $_->path } $step->buildstepoutputs->all); + showLog($c, $mode, $step->busy == 0, $step->drvpath, + map { $_->path } $step->buildstepoutputs->all); } sub view_log : Chained('buildChain') PathPart('log') { my ($self, $c, $mode) = @_; - showLog($c, $mode, $c->stash->{build}->drvpath, map { $_->path } $c->stash->{build}->buildoutputs->all); + showLog($c, $mode, $c->stash->{build}->finished, + $c->stash->{build}->drvpath, + map { $_->path } $c->stash->{build}->buildoutputs->all); } sub showLog { - my ($c, $mode, $drvPath, @outPaths) = @_; + my ($c, $mode, $finished, $drvPath, @outPaths) = @_; my $logPath = findLog($c, $drvPath, @outPaths); @@ -154,6 +157,7 @@ sub showLog { elsif ($mode eq "raw") { $c->stash->{logPath} = $logPath; + $c->stash->{finished} = $finished; $c->forward('Hydra::View::NixLog'); return; } diff --git a/src/lib/Hydra/View/NixLog.pm b/src/lib/Hydra/View/NixLog.pm index 4cbb2a74..fe10755c 100644 --- a/src/lib/Hydra/View/NixLog.pm +++ b/src/lib/Hydra/View/NixLog.pm @@ -20,7 +20,7 @@ sub process { } binmode($fh); - setCacheHeaders($c, 365 * 24 * 60 * 60); + setCacheHeaders($c, 365 * 24 * 60 * 60) if $c->stash->{finished}; $c->response->body($fh);