| 93 | |
| 94 | |
| 95 | hz::ExpectedVoid<StorageDetectorError> StorageDetector::fetch_basic_data(std::vector<StorageDevicePtr>& drives, |
| 96 | const CommandExecutorFactoryPtr& ex_factory, bool return_first_error) |
| 97 | { |
| 98 | fetch_data_errors_.clear(); |
| 99 | fetch_data_error_outputs_.clear(); |
| 100 | |
| 101 | std::shared_ptr<CommandExecutor> smartctl_ex = ex_factory->create_executor(CommandExecutorFactory::ExecutorType::Smartctl); |
| 102 | |
| 103 | for (auto& drive : drives) { |
| 104 | debug_out_info("app", "Retrieving basic information about the device...\n"); |
| 105 | |
| 106 | smartctl_ex->set_running_msg(Glib::ustring::compose(_("Running {command} on %1..."), drive->get_device_with_type())); |
| 107 | |
| 108 | // don't show any errors here - we don't want a screen flood. |
| 109 | // no need for gui-based executors here, we already show the message in |
| 110 | // iconview background (if called from main window) |
| 111 | hz::ExpectedVoid<StorageDeviceError> fetch_status; |
| 112 | if (drive->get_basic_output().empty()) { // if not fetched during detection |
| 113 | fetch_status = drive->fetch_basic_data_and_parse(smartctl_ex); |
| 114 | } |
| 115 | |
| 116 | // normally we skip drives with errors - possibly scsi, etc. |
| 117 | if (return_first_error && !fetch_status) { |
| 118 | return hz::Unexpected(StorageDetectorError::StorageDeviceError, fetch_status.error().message()); |
| 119 | } |
| 120 | |
| 121 | if (!fetch_status) { |
| 122 | // use original executor error if present (permits matches by our users). |
| 123 | // if (!smartctl_ex->get_error_msg().empty()) |
| 124 | // error_message = smartctl_ex->get_error_msg(); |
| 125 | |
| 126 | fetch_data_errors_.push_back(fetch_status.error().message()); |
| 127 | fetch_data_error_outputs_.push_back(smartctl_ex->get_stdout_str()); |
| 128 | } |
| 129 | |
| 130 | debug_out_dump("app", "Device information for " << drive->get_device() |
| 131 | << " (type: \"" << drive->get_type_argument() << "\"):\n" |
| 132 | << "\tModel: " << drive->get_model_name() << "\n" |
| 133 | << "\tDetected type: " << StorageDeviceDetectedTypeExt::get_displayable_name(drive->get_detected_type()) << "\n" |
| 134 | << "\tSMART status: " << StorageDevice::get_status_displayable_name(drive->get_smart_status()) << "\n" |
| 135 | ); |
| 136 | |
| 137 | } |
| 138 | |
| 139 | return {}; |
| 140 | } |
| 141 | |
| 142 | |
| 143 |
no test coverage detected