| 394 | |
| 395 | |
| 396 | hz::ExpectedVoid<StorageDeviceError> StorageDevice::parse_full_data(SmartctlParserType parser_type, SmartctlOutputFormat format) |
| 397 | { |
| 398 | // Clear everything fetched before, except outputs and disk type |
| 399 | clear_parse_results(); |
| 400 | |
| 401 | auto parser = SmartctlParser::create(parser_type, format); |
| 402 | DBG_ASSERT_RETURN(parser, hz::Unexpected(StorageDeviceError::ParseError, _("Cannot create parser"))); |
| 403 | |
| 404 | const auto parse_status = parser->parse(this->full_output_); |
| 405 | if (parse_status.has_value()) { |
| 406 | set_parse_status(parser_type == SmartctlParserType::Basic ? ParseStatus::Basic : ParseStatus::Full); |
| 407 | |
| 408 | // Detect drive type based on parsed properties |
| 409 | detect_drive_type_from_properties(parser->get_property_repository()); |
| 410 | |
| 411 | // Set the full properties, overwriting old data. |
| 412 | set_property_repository(StoragePropertyProcessor::process_properties(parser->get_property_repository(), get_detected_type())); |
| 413 | |
| 414 | // Read common properties from the repository. |
| 415 | read_common_properties(); |
| 416 | |
| 417 | signal_changed().emit(this); // notify listeners |
| 418 | |
| 419 | return {}; |
| 420 | } |
| 421 | |
| 422 | std::string message = parse_status.error().message(); |
| 423 | return hz::Unexpected(StorageDeviceError::ParseError, |
| 424 | fmt::format(fmt::runtime(_("Cannot parse smartctl output: {}")), message)); |
| 425 | } |
| 426 | |
| 427 | |
| 428 |
no test coverage detected