From a142e1c73f28acd82da02b9d41f7ada2df653d37 Mon Sep 17 00:00:00 2001 From: Thomas Hille Date: Wed, 22 Mar 2017 17:30:20 +0100 Subject: [PATCH] save messages returned from runs --- app/controllers/submissions_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 361ed866..2c7ed9f2 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -13,6 +13,10 @@ class SubmissionsController < ApplicationController before_action :set_mime_type, only: [:download_file, :render_file] skip_before_action :verify_authenticity_token, only: [:download_file, :render_file] + def max_message_buffer_size + 500 + end + def authorize! authorize(@submission || @submissions) end @@ -172,15 +176,21 @@ class SubmissionsController < ApplicationController end def handle_message(message, tubesock, container) + @message_buffer ||= "" # Handle special commands first if (/^#exit/.match(message)) kill_socket(tubesock) + @docker_client.exit_container(container) + if !@message_buffer.blank? + Testrun.create(file: @file, submission: @submission, output: @message_buffer) + end else # Filter out information about run_command, test_command, user or working directory run_command = @submission.execution_environment.run_command % command_substitutions(params[:filename]) test_command = @submission.execution_environment.test_command % command_substitutions(params[:filename]) if !(/root|workspace|#{run_command}|#{test_command}/.match(message)) + @message_buffer += message if @message_buffer.size <= max_message_buffer_size parse_message(message, 'stdout', tubesock) end end