From 2080d5ab0b028739af2d9770a176b6bd7962036f Mon Sep 17 00:00:00 2001 From: Martin Polanka Date: Sat, 5 May 2018 16:31:29 +0200 Subject: [PATCH] Call forgotten method after execution of sandbox. Tune exceptions in filesystem hleper. Check for existance of evaluation sandbox directory. --- src/helpers/filesystem.cpp | 11 +++++++---- src/tasks/external_task.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/helpers/filesystem.cpp b/src/helpers/filesystem.cpp index 16e696d3..7e656ad2 100644 --- a/src/helpers/filesystem.cpp +++ b/src/helpers/filesystem.cpp @@ -5,11 +5,14 @@ void helpers::copy_directory(const fs::path &src, const fs::path &dest) { try { if (!fs::exists(src)) { - throw filesystem_exception("Source directory does not exist"); + throw filesystem_exception( + "helpers::copy_directory: Source directory does not exist '" + src.string() + "'"); } else if (!fs::is_directory(src)) { - throw filesystem_exception("Source directory is not a directory"); + throw filesystem_exception( + "helpers::copy_directory: Source directory is not a directory '" + src.string() + "'"); } else if (!fs::exists(dest) && !fs::create_directories(dest)) { - throw filesystem_exception("Destination directory cannot be created"); + throw filesystem_exception( + "helpers::copy_directory: Destination directory cannot be created '" + dest.string() + "'"); } fs::directory_iterator endit; @@ -21,7 +24,7 @@ void helpers::copy_directory(const fs::path &src, const fs::path &dest) } } } catch (fs::filesystem_error &e) { - throw filesystem_exception("Error in copying directories: " + std::string(e.what())); + throw filesystem_exception("helpers::copy_directory: Error in copying directories: " + std::string(e.what())); } return; diff --git a/src/tasks/external_task.cpp b/src/tasks/external_task.cpp index 4d346d3e..e94d3400 100644 --- a/src/tasks/external_task.cpp +++ b/src/tasks/external_task.cpp @@ -84,6 +84,11 @@ std::shared_ptr external_task::run() // initialize output from stdout and stderr results_output_init(); + // check if evaluation directory exists + if (!fs::exists(evaluation_dir_)) { + throw task_exception("Evaluation directory '" + evaluation_dir_.string() + "' of sandbox does not exists"); + } + // check if binary is executable and set it otherwise make_binary_executable(task_meta_->binary); @@ -145,6 +150,7 @@ void external_task::get_results_output(std::shared_ptr result) fs::path stdout_file_path = find_path_outside_sandbox(sandbox_config_->std_output); fs::path stderr_file_path = find_path_outside_sandbox(sandbox_config_->std_error); process_results_output(result, stdout_file_path, stderr_file_path); + process_carboncopy_output(stdout_file_path, stderr_file_path); // delete produced files if requested try {