SPE-2451: Handling of already broken manifest file.

Fix of false has_installed_printers entry in manifest.
Move saving manifest to place where appconfig is changed as well.
This commit is contained in:
David Kocik 2024-08-23 11:28:23 +02:00 committed by Lukas Matena
parent 593ac53cdd
commit 0285ba2d84
2 changed files with 31 additions and 12 deletions

View File

@ -3333,17 +3333,6 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
const auto enabled_vendors = appconfig_new.vendors();
const auto enabled_vendors_old = app_config->vendors();
std::vector<std::string> used_repo_ids;
for (const auto& vendor : enabled_vendors) {
const auto& it = bundles.find(vendor.first);
assert(it != bundles.end());
const std::string repo_id = it->second.vendor_profile->repo_id;
if (std::find(used_repo_ids.begin(), used_repo_ids.end(), repo_id) == used_repo_ids.end()) {
used_repo_ids.emplace_back(repo_id);
}
}
wxGetApp().plater()->get_preset_archive_database()->set_installed_printer_repositories(std::move(used_repo_ids));
bool suppress_sla_printer = model_has_multi_part_objects(wxGetApp().model());
PrinterTechnology preferred_pt = ptAny;
auto get_preferred_printer_technology = [enabled_vendors, enabled_vendors_old, suppress_sla_printer](const std::string& bundle_name, const Bundle& bundle) {
@ -3577,6 +3566,36 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
}
}
// Save used repo into manifest.
std::vector<std::string> used_repo_ids;
for (const auto& vendor : enabled_vendors) {
// here vendor might be empty - it causes false has_installed_printers : 1 entries in manifest.
if (vendor.second.empty()){
continue;
}
bool not_empty = false;
for (const auto& it : vendor.second) {
if (!it.second.empty()) {
not_empty = true;
break;
}
}
if (!not_empty) {
continue;
}
const auto& it = bundles.find(vendor.first);
// This is a last resort solution of missing secret repo in manifest while some of its printers are installed.
if (it == bundles.end()) {
continue;
}
const std::string repo_id = it->second.vendor_profile->repo_id;
if (std::find(used_repo_ids.begin(), used_repo_ids.end(), repo_id) == used_repo_ids.end()) {
used_repo_ids.emplace_back(repo_id);
}
}
wxGetApp().plater()->get_preset_archive_database()->set_installed_printer_repositories(std::move(used_repo_ids));
// apply materials in app_config
for (const std::string& section_name : {AppConfig::SECTION_FILAMENTS, AppConfig::SECTION_MATERIALS})
if (appconfig_new.has_section(section_name))

View File

@ -689,7 +689,7 @@ void PresetArchiveDatabase::clear_online_repos()
{
auto it = m_archive_repositories.begin();
while (it != m_archive_repositories.end()) {
// Do not clean repos with local path (local repo) and with visibility filled (secret repo)
// Do not clean repos with local path (local repo).
if ((*it)->get_manifest().tmp_path.empty()) {
it = m_archive_repositories.erase(it);
} else {