Skip to content
API Documentation
BastionGuard™
recovery_worker.cpp
Go to the documentation of this file.
1#include "recovery_worker.hpp"
3
5
11
13 const std::string& output_dir,
14 const std::vector<size_t>& selected_result_indices,
16{
17 if (running_)
18 return;
19
20 cancel_requested_ = false;
21 running_ = true;
22
23 thread_ = std::thread([this, report, output_dir, selected_result_indices, cb]()
24 {
26
27 try
28 {
30 report,
31 output_dir,
32 selected_result_indices,
33 rr.summary,
34 rr.logs,
35 rr.error,
36 [this]() { return cancel_requested_.load(); }
37 );
38 }
39 catch (const std::exception& e)
40 {
41 rr.ok = false;
42 rr.error = std::string("Recovery exception: ") + e.what();
43 }
44 catch (...)
45 {
46 rr.ok = false;
47 rr.error = "Unknown recovery exception";
48 }
49
50 running_ = false;
51
52 if (!cancel_requested_ && cb)
53 cb(rr);
54 });
55}
56
58{
59 return running_;
60}
61
63{
64 if (thread_.joinable())
65 thread_.join();
66}
67
static bool export_results_and_carve(const ScanReport &report, const std::string &output_dir, const std::vector< size_t > &selected_result_indices, RecoverySummary &summary, std::vector< std::string > &logs, std::string &error, CancelCallback cancel_cb)
void start(const ScanReport &report, const std::string &output_dir, const std::vector< size_t > &selected_result_indices, CompletionCallback cb)
std::atomic< bool > cancel_requested_
bool running() const
std::function< void(const RecoveryResult &)> CompletionCallback
std::thread thread_
std::atomic< bool > running_
RecoverySummary summary
std::vector< std::string > logs