Skip to content

Commit

Permalink
Call forgotten method after execution of sandbox. Tune exceptions in …
Browse files Browse the repository at this point in the history
…filesystem hleper. Check for existance of evaluation sandbox directory.
  • Loading branch information
Neloop committed May 10, 2018
1 parent 1c8c28b commit 2080d5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/helpers/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/tasks/external_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ std::shared_ptr<task_results> 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);

Expand Down Expand Up @@ -145,6 +150,7 @@ void external_task::get_results_output(std::shared_ptr<task_results> 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 {
Expand Down

0 comments on commit 2080d5a

Please sign in to comment.