diff --git a/docs/upgrades/upgrade_7.10.23-7.10.24.pl b/docs/upgrades/upgrade_7.10.23-7.10.24.pl index e28dc8ee7..28b8c8ca4 100644 --- a/docs/upgrades/upgrade_7.10.23-7.10.24.pl +++ b/docs/upgrades/upgrade_7.10.23-7.10.24.pl @@ -32,6 +32,7 @@ my $session = start(); # this line required # upgrade functions go here addPALastLogTable($session); +addForkRedirect($session); finish($session); # this line required @@ -55,6 +56,18 @@ EOSQL print "DONE!\n" unless $quiet; } +#---------------------------------------------------------------------------- +# Describe what our function does +sub addForkRedirect { + my $session = shift; + print "\tAdd a column to Fork to keep track of late generated redirect URLs... " unless $quiet; + # and here's our code + $session->db->write(<{redirect}; $self->set( \%props ); } @@ -514,6 +515,20 @@ sub setGroup { #----------------------------------------------------------------- +=head2 setRedirect($url) + +Allows a redirect to be set for the process after the initial fork. This happens +in the case when a file is to be downloaded after the fork finishes. + +=cut + +sub setRedirect { + my ( $self, $url ) = @_; + $self->{redirect} = $url; +} + +#----------------------------------------------------------------- + =head2 request ($module, $subname, $data) Internal method. Generates a hashref suitable for passing to runRequest. diff --git a/lib/WebGUI/Fork/Status.pm b/lib/WebGUI/Fork/Status.pm index 06c2ebd3b..881d664d9 100644 --- a/lib/WebGUI/Fork/Status.pm +++ b/lib/WebGUI/Fork/Status.pm @@ -67,7 +67,7 @@ See the synopsis for what kind of response this generates. sub handler { my $process = shift; my $status = $process->getStatus; - my ( $finished, $startTime, $endTime, $error ) = $process->get( 'finished', 'startTime', 'endTime', 'error' ); + my ( $finished, $startTime, $endTime, $error, $redirect ) = $process->get( qw/finished startTime endTime error redirect/ ); $endTime = time() unless $finished; @@ -76,7 +76,8 @@ sub handler { elapsed => ( $endTime - $startTime ), finished => ( $finished ? \1 : \0 ), ); - $status{error} = $error if $finished; + $status{error} = $error if $finished; + $status{redirect} = $redirect if $finished; $process->session->http->setMimeType('text/plain'); JSON::encode_json( \%status ); } ## end sub handler diff --git a/www/extras/Fork/poll.js b/www/extras/Fork/poll.js index 5bb1a7761..6a86cb8c9 100644 --- a/www/extras/Fork/poll.js +++ b/www/extras/Fork/poll.js @@ -26,7 +26,7 @@ args.first(); } if (data.finished) { - args.finish(); + args.finish(data); } else { setTimeout(fetch, args.interval || 1000);