MCPcopy Create free account
hub / github.com/ashaduri/gsmartcontrol / parse_full_data

Method parse_full_data

src/applib/storage_device.cpp:396–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394
395
396hz::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

Callers 1

Calls 6

createFunction · 0.85
UnexpectedFunction · 0.85
formatFunction · 0.50
runtimeFunction · 0.50
parseMethod · 0.45
has_valueMethod · 0.45

Tested by

no test coverage detected