| 495 | } |
| 496 | |
| 497 | static bool tryLoadIndex(const ObjectFoldersState& currentState) |
| 498 | { |
| 499 | Core::Timer loadTimer; |
| 500 | |
| 501 | const auto indexPath = Environment::getPathNoWarning(Environment::PathId::plugin1); |
| 502 | if (!fs::exists(indexPath)) |
| 503 | { |
| 504 | Logging::verbose("Object index does not exist."); |
| 505 | return false; |
| 506 | } |
| 507 | FileStream stream; |
| 508 | stream.open(indexPath, StreamMode::read); |
| 509 | if (!stream.isOpen()) |
| 510 | { |
| 511 | Logging::error("Unable to load the object index."); |
| 512 | return false; |
| 513 | } |
| 514 | |
| 515 | try |
| 516 | { |
| 517 | auto header = deserialiseHeader(stream); |
| 518 | if (header.version != kCurrentIndexVersion || header.state != currentState) |
| 519 | { |
| 520 | return false; |
| 521 | } |
| 522 | else |
| 523 | { |
| 524 | _installedObjectList = deserialiseIndex(stream); |
| 525 | if (_installedObjectList.empty()) |
| 526 | { |
| 527 | return false; |
| 528 | } |
| 529 | Logging::verbose("Loaded object index in {} milliseconds.", loadTimer.elapsed()); |
| 530 | } |
| 531 | } |
| 532 | catch (const std::runtime_error& ex) |
| 533 | { |
| 534 | Logging::error("Unable to load the object index: {}", ex.what()); |
| 535 | return false; |
| 536 | } |
| 537 | |
| 538 | reloadAll(); |
| 539 | |
| 540 | return true; |
| 541 | } |
| 542 | |
| 543 | // 0x00470F3C |
| 544 | void loadIndex() |
no test coverage detected