Skip to content

Commit

Permalink
Copy sandboxed dir back on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SemaiCZE committed Oct 11, 2018
1 parent 4e45d94 commit 8da3470
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/sandbox/isolate_sandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,19 @@ sandbox_results isolate_sandbox::run(const std::string &binary, const std::vecto
// move data to isolate directory
if (data_dir_ != "") { move_or_throw(logger_, data_dir_, sandboxed_dir_); }

// run isolate
isolate_run(binary, arguments);
try {
// run isolate
isolate_run(binary, arguments);

// move data from isolate directory back to data directory
if (data_dir_ != "") { move_or_throw(logger_, sandboxed_dir_, data_dir_); }
} catch (const std::exception &) {
// on errors also move data from isolate directory back to data directory
if (data_dir_ != "") { move_or_throw(logger_, sandboxed_dir_, data_dir_); }

// move data from isolate directory back to data directory
if (data_dir_ != "") { move_or_throw(logger_, sandboxed_dir_, data_dir_); }
// rethrow the original exception when data are saved
throw;
}

return process_meta_file();
}
Expand Down

0 comments on commit 8da3470

Please sign in to comment.