Compatibility checks and preset loading.

PresetUpdater: clear cache/vendor before sync_config
GUI_App: Check updates operation with new steps
ConfigWizard: run updater sync on wizard startup and repo change confirmation
Compatibvility check for Prusa SLA - Mockup.
This commit is contained in:
David Kocik 2024-05-15 16:40:00 +02:00
parent e1229a86fc
commit 52d01478ea
13 changed files with 3851 additions and 22 deletions

View File

@ -1,9 +1,17 @@
[{
"name": "Production",
"description": "Production repository",
"name": "Prusa FFF",
"description": "Prusa FFF printers",
"visibility": "",
"id": "prod",
"url": "http://10.24.3.3:8001/v1/repos/prod/",
"index_url": "http://10.24.3.3:8001/v1/repos/prod/vendor_indices.zip",
"id": "prusa-fff",
"url": "http://10.24.3.3:8001/v1/repos/prusa-fff",
"index_url": "http://10.24.3.3:8001/v1/repos/prusa-fff/vendor_indices.zip",
"selected" : 1
}, {
"name": "Prusa SLA",
"description": "Prusa SLA printers",
"visibility": "",
"id": "prusa-sla",
"url": "http://10.24.3.3:8001/v1/repos/prusa-sla",
"index_url": "http://10.24.3.3:8001/v1/repos/prusa-sla/vendor_indices.zip",
"selected" : 1
}]

View File

@ -1,5 +1,7 @@
min_slic3r_version = 2.7.5-rc
1.14.0 Added new settings for SLA material profiles.
2.0.0-alpha0 Initial bundle for PS2.8.0-alpha.
min_slic3r_version = 2.8.0-alpha0
min_slic3r_version = 2.7.3-beta1
1.13.4 Updated FW version notification (6.0.1). Added ROSA3D filaments. Updated print profiles for 0.6 nozzle. Updated perimeter speeds in "0.10mm FAST DETAIL" profile (MK4/XL). Slightly increased nozzle temperature for Generic PETG/Prusa PETG/Prusament PETG (0.6n).
1.13.3 Updated FW version notification.

View File

@ -1,19 +1,21 @@
# Print profiles for Prusa Research printers.
[vendor]
repo_id = prusa-fff
# Vendor name will be shown by the Config Wizard.
name = Prusa Research
# Configuration version of this file. Config file will only be installed, if the config_version differs.
# This means, the server may force the PrusaSlicer configuration to be downgraded.
config_version = 1.14.0
config_version = 2.0.0-alpha0
# Where to get the updates from?
config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaResearch/
# config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaResearch/
changelog_url = https://files.prusa3d.com/?latest=slicer-profiles&lng=%1%
# The printer models will be shown by the Configuration Wizard in this order,
# also the first model installed & the first nozzle installed will be activated after install.
# Printer model name will be shown by the installation wizard.
config_url = http://10.24.3.3:8001/v1/repos/prusa-fff/PrusaResearch/
[printer_model:MK4IS]
name = Original Prusa MK4 Input Shaper
variants = 0.4; 0.25; 0.3; 0.5; 0.6; 0.8
@ -43,6 +45,7 @@ bed_model = mk4_bed.stl
bed_texture = mk4.svg
default_materials = Generic PLA @PG; Generic ABS @MK4; Generic PETG @PG; Prusament PLA @PG; Prusament rPLA @PG; Prusament PETG @PG; Prusament ASA @MK4; Prusament PC Blend @MK4; Prusament PC Blend Carbon Fiber @MK4; Prusament PVB @PG; Prusament PA11 Carbon Fiber @PG
thumbnail = MK4_thumbnail.png
[printer_model:MK3.9]
name = Original Prusa MK3.9 Input Shaper
variants = 0.4; 0.25; 0.3; 0.5; 0.6; 0.8
@ -102,6 +105,7 @@ bed_model = mini_bed.stl
bed_texture = mini.svg
default_materials = Generic PLA; Generic ABS @MINI; Generic PETG @MINI; Prusament PLA; Prusament rPLA; Prusament PETG @MINI; Prusament ASA @MINI; Prusament PC Blend @MINI; Prusament PC Blend Carbon Fiber @MINI; Prusament PVB
thumbnail = MINI_thumbnail.png
[printer_model:MK3S]
name = Original Prusa i3 MK3S && MK3S+
variants = 0.4; 0.25; 0.6; 0.8
@ -111,6 +115,7 @@ bed_model = mk3_bed.stl
bed_texture = mk3.svg
default_materials = Generic PLA; Generic ABS; Generic PETG; Prusament PLA; Prusament rPLA; Prusament PETG; Prusament ASA; Prusament PC Blend; Prusament PC Blend Carbon Fiber; Prusament PVB; Prusament PA11 Carbon Fiber
thumbnail = MK3S_thumbnail.png
[printer_model:MK3]
name = Original Prusa i3 MK3
variants = 0.4; 0.25; 0.6; 0.8
@ -120,6 +125,7 @@ bed_model = mk3_bed.stl
bed_texture = mk3.svg
default_materials = Generic PLA; Generic ABS; Generic PETG; Prusament PLA; Prusament rPLA; Prusament PETG; Prusament ASA; Prusament PC Blend; Prusament PC Blend Carbon Fiber; Prusament PVB; Prusament PA11 Carbon Fiber
thumbnail = MK3_thumbnail.png
[printer_model:MK3SMMU3]
name = Original Prusa i3 MK3S && MK3S+ MMU3
variants = 0.4; 0.25; 0.6; 0.8
@ -129,6 +135,7 @@ bed_model = mk3_bed.stl
bed_texture = mk3.svg
default_materials = Generic PLA; Generic ABS; Generic PETG; Prusament PLA @MMU; Prusament PETG @MMU; Prusament ASA @MMU; Verbatim BVOH @MMU; Prusament PC Blend @MMU; Prusament PC Blend Carbon Fiber @MMU; Prusament PVB @MMU
thumbnail = MK3SMMU3_thumbnail.png
[printer_model:MK3SMMU2S]
name = Original Prusa i3 MK3S && MK3S+ MMU2S
variants = 0.4; 0.25; 0.6; 0.8
@ -138,6 +145,7 @@ bed_model = mk3_bed.stl
bed_texture = mk3.svg
default_materials = Generic PLA; Generic ABS; Generic PETG; Prusament PLA @MMU; Prusament PETG @MMU; Prusament ASA @MMU; Verbatim BVOH @MMU; Prusament PC Blend @MMU; Prusament PC Blend Carbon Fiber @MMU; Prusament PVB @MMU
thumbnail = MK3SMMU2S_thumbnail.png
[printer_model:MK3MMU2]
name = Original Prusa i3 MK3 MMU2
variants = 0.4; 0.25; 0.6; 0.8
@ -147,6 +155,7 @@ bed_model = mk3_bed.stl
bed_texture = mk3.svg
default_materials = Generic PLA; Generic ABS; Generic PETG; Prusament PLA @MMU; Prusament PETG @MMU; Prusament ASA @MMU; Verbatim BVOH @MMU; Prusament PC Blend @MMU; Prusament PC Blend Carbon Fiber @MMU; Prusament PVB @MMU
thumbnail = MK3MMU2_thumbnail.png
[printer_model:XLIS]
name = Original Prusa XL Input Shaper
variants = 0.4; 0.25; 0.3; 0.5; 0.6; 0.8
@ -166,6 +175,7 @@ bed_model = xl_bed.stl
bed_texture = xl.svg
default_materials = Generic PLA @XL; Generic ABS @XL; Generic PETG @XL; Prusament PLA @XL; Prusament rPLA @XL; Prusament PETG @XL; Prusament ASA @XL; Prusament PC Blend @XL; Prusament PC Blend Carbon Fiber @XL; Prusament PVB @XL; Prusament PA11 Carbon Fiber @XL
thumbnail = XL_thumbnail.png
[printer_model:XL2IS]
name = Original Prusa XL - 2T Input Shaper
variants = 0.4; 0.25; 0.3; 0.5; 0.6; 0.8
@ -185,6 +195,7 @@ bed_model = xl_bed.stl
bed_texture = xl.svg
default_materials = Generic PLA @XL; Generic ABS @XL; Generic PETG @XL; Prusament PLA @XL; Prusament rPLA @XL; Prusament PETG @XL; Prusament ASA @XL; Prusament PC Blend @XL; Prusament PC Blend Carbon Fiber @XL; Prusament PVB @XL; Prusament PA11 Carbon Fiber @XL; Verbatim BVOH @XL
thumbnail = XL2_thumbnail.png
[printer_model:XL5IS]
name = Original Prusa XL - 5T Input Shaper
variants = 0.4; 0.25; 0.3; 0.5; 0.6; 0.8
@ -204,6 +215,7 @@ bed_model = xl_bed.stl
bed_texture = xl.svg
default_materials = Generic PLA @XL; Generic ABS @XL; Generic PETG @XL; Prusament PLA @XL; Prusament rPLA @XL; Prusament PETG @XL; Prusament ASA @XL; Prusament PC Blend @XL; Prusament PC Blend Carbon Fiber @XL; Prusament PVB @XL; Prusament PA11 Carbon Fiber @XL; Verbatim BVOH @XL
thumbnail = XL5_thumbnail.png
[printer_model:MK2.5S]
name = Original Prusa i3 MK2.5S
variants = 0.4; 0.25; 0.6; 0.8
@ -213,6 +225,7 @@ bed_model = mk3_bed.stl
bed_texture = mk3.svg
default_materials = Generic PLA; Generic ABS; Generic PETG; Prusament PLA; Prusament rPLA; Prusament PETG; Prusament ASA; Prusament PC Blend; Prusament PC Blend Carbon Fiber; Prusament PVB; Prusament PA11 Carbon Fiber @MK2
thumbnail = MK2.5S_thumbnail.png
[printer_model:MK2.5]
name = Original Prusa i3 MK2.5
variants = 0.4; 0.25; 0.6; 0.8
@ -222,6 +235,7 @@ bed_model = mk3_bed.stl
bed_texture = mk3.svg
default_materials = Generic PLA; Generic ABS; Generic PETG; Prusament PLA; Prusament rPLA; Prusament PETG; Prusament ASA; Prusament PC Blend; Prusament PC Blend Carbon Fiber; Prusament PVB; Prusament PA11 Carbon Fiber @MK2
thumbnail = MK2.5_thumbnail.png
[printer_model:MK2.5SMMU2S]
name = Original Prusa i3 MK2.5S MMU2S
variants = 0.4; 0.25; 0.6; 0.8
@ -231,6 +245,7 @@ bed_model = mk3_bed.stl
bed_texture = mk3.svg
default_materials = Generic PLA; Generic ABS; Generic PETG; Prusament PLA @MMU; Prusament PETG @MMU; Prusament ASA @MMU; Verbatim BVOH @MMU; Prusament PC Blend @MMU; Prusament PC Blend Carbon Fiber @MMU; Prusament PVB @MMU
thumbnail = MK2.5SMMU2S_thumbnail.png
[printer_model:MK2.5MMU2]
name = Original Prusa i3 MK2.5 MMU2
variants = 0.4; 0.25; 0.6; 0.8
@ -240,6 +255,7 @@ bed_model = mk3_bed.stl
bed_texture = mk3.svg
default_materials = Generic PLA; Generic ABS; Generic PETG; Prusament PLA @MMU; Prusament PETG @MMU; Prusament ASA @MMU; Verbatim BVOH @MMU; Prusament PC Blend @MMU; Prusament PC Blend Carbon Fiber @MMU; Prusament PVB @MMU
thumbnail = MK2.5MMU2_thumbnail.png
[printer_model:MK2S]
name = Original Prusa i3 MK2S
variants = 0.4; 0.25; 0.6
@ -249,6 +265,7 @@ bed_model = mk2_bed.stl
bed_texture = mk2.svg
default_materials = Generic PLA; Generic ABS; Generic PETG; Prusament PLA; Prusament rPLA; Prusament PETG; Prusament ASA; Prusament PC Blend; Prusament PC Blend Carbon Fiber; Prusament PVB; Prusament PA11 Carbon Fiber @MK2
thumbnail = MK2S_thumbnail.png
[printer_model:MK2SMM]
name = Original Prusa i3 MK2S MMU1
variants = 0.4; 0.6
@ -281,6 +298,7 @@ default_materials = Prusament Resin Tough Prusa Orange @0.05 SL1S
# Common print presets
thumbnail = MK2SMM_thumbnail.png
[print:*common*]
avoid_crossing_perimeters = 0
thick_bridges = 0

View File

@ -0,0 +1,3 @@
min_slic3r_version = 2.8.0-alpha0
1.0.0-alpha0 Initial bundle for PS2.8.0-alpha.
max_slic3r_version = 2.7.4

File diff suppressed because it is too large Load Diff

View File

@ -161,7 +161,8 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
res.repo_id = repo_id->second.data();
} else {
// For backward compatibility assume all profiles without repo_id are from "prod" repo
res.repo_id = "prod";
// DK: "No, dont!"
res.repo_id = "";
}
if (! load_all) {

View File

@ -129,6 +129,7 @@ BundleMap BundleMap::load()
{
BundleMap res;
const PresetArchiveDatabase* pad = wxGetApp().plater()->get_preset_archive_database();
const auto vendor_dir = (boost::filesystem::path(Slic3r::data_dir()) / "vendor").make_preferred();
const auto archive_dir = (boost::filesystem::path(Slic3r::data_dir()) / "cache" / "vendor").make_preferred();
const auto rsrc_vendor_dir = (boost::filesystem::path(resources_dir()) / "profiles").make_preferred();
@ -182,6 +183,96 @@ BundleMap BundleMap::load()
continue;
}
Slic3r::GUI::Config::Index index;
try {
index.load(idx_path);
}
catch (const std::exception& /* err */) {
BOOST_LOG_TRIVIAL(error) << format("Could not load bundle %1% due to invalid index %2%.", id, idx_path.string());
continue;
}
const auto recommended_it = index.recommended();
if (recommended_it == index.end()) {
BOOST_LOG_TRIVIAL(error) << format("Could not load bundle %1% due to no recommended version in index %2%.", id, idx_path.string());
continue;
}
const auto recommended = recommended_it->config_version;
VendorProfile vp;
// Check if in selected repo.
try {
vp = VendorProfile::from_ini(dir_entry, false);
}
catch (const std::exception& e) {
BOOST_LOG_TRIVIAL(error) << format("Could not load bundle %1% due to corrupted profile file %2%. Message: %3%", id, dir_entry.path().string(), e.what());
continue;
}
if (vp.repo_id.empty() || !pad->is_selected_repository_by_id(vp.repo_id)) {
continue;
}
// Don't load
if (vp.config_version > recommended)
continue;
// Load full VP.
try {
vp = VendorProfile::from_ini(dir_entry, true);
}
catch (const std::exception& e) {
BOOST_LOG_TRIVIAL(error) << format("Could not load bundle %1% due to corrupted profile file %2%. Message: %3%", id, dir_entry.path().string(), e.what());
continue;
}
Bundle bundle;
if (bundle.load(dir_entry.path(), dir.second))
res.emplace(std::move(id), std::move(bundle));
}
}
}
return res;
}
#if 0
// Reload is a mockup of a function that takes existing BundleMap and reshapes it into current form.
// It would be called after calling preset_updater->sync_blocking() and preset_updater->config_update() instead of fully loading it from scratch.
// Some entries will stop existing because its repositories were unselected.
// Missing: Entries that changed location: e.g. newer ini is now ready in archive_dir, while previously it was in rsrc_vendor_dir
void BundleMap::reload(BundleMap& res)
{
const auto vendor_dir = (boost::filesystem::path(Slic3r::data_dir()) / "vendor").make_preferred();
const auto archive_dir = (boost::filesystem::path(Slic3r::data_dir()) / "cache" / "vendor").make_preferred();
const auto rsrc_vendor_dir = (boost::filesystem::path(resources_dir()) / "profiles").make_preferred();
const auto cache_dir = boost::filesystem::path(Slic3r::data_dir()) / "cache"; // for Index
// Load the other bundles in the datadir/vendor directory
// and then additionally from datadir/cache/vendor (archive) and resources/profiles.
// Should we concider case where archive has older profiles than resources (shouldnt happen)? -> YES, it happens during re-configuration when running older PS after newer version
typedef std::pair<const fs::path&, BundleLocation> DirData;
std::vector<DirData> dir_list{ {vendor_dir, BundleLocation::IN_VENDOR}, {archive_dir, BundleLocation::IN_ARCHIVE}, {rsrc_vendor_dir, BundleLocation::IN_RESOURCES} };
for (auto dir : dir_list) {
if (!fs::exists(dir.first))
continue;
for (const auto& dir_entry : boost::filesystem::directory_iterator(dir.first)) {
if (Slic3r::is_ini_file(dir_entry)) {
std::string id = dir_entry.path().stem().string(); // stem() = filename() without the trailing ".ini" part
// Don't load this bundle if we've already loaded it.
if (res.find(id) != res.end()) { continue; }
// Fresh index should be in archive_dir, otherwise look for it in cache
// Then if not in archive or cache - it could be 3rd party profile that user just copied to vendor folder (both ini and cache)
fs::path idx_path(archive_dir / (id + ".idx"));
if (!boost::filesystem::exists(idx_path)) {
BOOST_LOG_TRIVIAL(error) << format("Missing index %1% when loading bundle %2%. Going to search for it in cache folder.", idx_path.string(), id);
idx_path = fs::path(cache_dir / (id + ".idx"));
}
if (!boost::filesystem::exists(idx_path)) {
BOOST_LOG_TRIVIAL(error) << format("Missing index %1% when loading bundle %2%. Going to search for it in vendor folder. Is it a 3rd party profile?", idx_path.string(), id);
idx_path = fs::path(vendor_dir / (id + ".idx"));
}
if (!boost::filesystem::exists(idx_path)) {
BOOST_LOG_TRIVIAL(error) << format("Could not load bundle %1% due to missing index %2%.", id, idx_path.string());
continue;
}
Slic3r::GUI::Config::Index index;
try {
index.load(idx_path);
@ -215,8 +306,32 @@ BundleMap BundleMap::load()
}
}
return res;
// Delete no longer existing entries and not used repos
const PresetArchiveDatabase* pad = wxGetApp().plater()->get_preset_archive_database();
std::vector<std::string> to_erease;
for (const auto& entry : res) {
fs::path ini_path;
switch (entry.second.location) {
case IN_VENDOR: ini_path = vendor_dir / (entry.first + ".ini"); break;
case IN_ARCHIVE: ini_path = archive_dir / (entry.first + ".ini"); break;
case IN_RESOURCES: ini_path = rsrc_vendor_dir / (entry.first + ".ini"); break;
default: assert(true);
}
if (!fs::exists(ini_path)) {
to_erease.emplace_back(entry.first);
continue;
}
if (entry.second.vendor_profile->repo_id.empty() || !pad->is_selected_repository_by_id(entry.second.vendor_profile->repo_id))
{
to_erease.emplace_back(entry.first);
}
}
for (const std::string& id : to_erease)
{
res.erase(id);
}
}
#endif // 0
Bundle& BundleMap::prusa_bundle()
{
@ -3451,6 +3566,25 @@ bool ConfigWizard::priv::check_sla_selected()
void ConfigWizard::priv::set_config_updated_from_archive(bool is_updated)
{
// is updated is false if this is first call since ConfigWizard::run and RunReason is not RR_USER
if (is_updated)
{
// THIS IS NOT A MAIN THREAD!
// This set with preset_updater used to be done in GUI_App::run_wizard before ConfigWizard::run()
GUI_App& app = wxGetApp();
// Do blocking sync on every change of archive repos, so user is always offered recent profiles.
app.preset_updater->sync_blocking(app.preset_bundle, &app, app.plater()->get_preset_archive_database()->get_archive_repositories(), app.plater()->get_preset_archive_database()->get_selected_repositories_uuid());
// Offer update installation. It used to be offered only when wizard run reason was RR_USER.
app.preset_updater->update_index_db();
app.preset_updater->config_update(app.app_config->orig_version(), PresetUpdater::UpdateParams::SHOW_TEXT_BOX);
// We have now probably changed data. We need to rebuild or database from which wizards constructs.
// DK: Im not sure if we should do full load_vendors. or only load BundleMap::load().
// also see BundleMap::reload().
load_vendors();
}
is_config_from_archive = is_updated;
load_pages_from_archive();
}
@ -3484,7 +3618,7 @@ static void unselect(PagePrinters* page)
for (const auto& archive : archs) {
if (page->get_vendor_repo_id() == archive->get_manifest().id) {
if (pad->is_selected_archive(archive->get_uuid()))
if (pad->is_selected_repository_by_uuid(archive->get_uuid()))
unselect_all = false;
//break; ! don't break here, because there can be several archives with same repo_id
}
@ -3543,7 +3677,7 @@ void ConfigWizard::priv::load_pages_from_archive()
for (const auto& archive : archs) {
const auto& data = archive->get_manifest();
const bool is_selected_arch = pad->is_selected_archive(archive->get_uuid());
const bool is_selected_arch = pad->is_selected_repository_by_uuid(archive->get_uuid());
std::vector<const VendorProfile*> vendors;
const bool any_installed_vendor = any_installed_vendor_for_repo(data.id, vendors);

View File

@ -834,10 +834,11 @@ void GUI_App::post_init()
return;
#endif
CallAfter([this] {
// preset_updater->sync downloads profile updates and than via event checks updates and incompatible presets. We need to run it on startup.
// start before cw so it is canceled by cw if needed?
this->preset_updater->sync(preset_bundle, this, plater()->get_preset_archive_database()->get_archive_repositories(), plater()->get_preset_archive_database()->get_selected_repositories_uuid());
bool cw_showed = this->config_wizard_startup();
if (! cw_showed) {
// preset_updater->sync downloads profile updates on background so it must begin after config wizard finished.
this->preset_updater->sync(preset_bundle, this, plater()->get_preset_archive_database()->get_archive_repositories(), plater()->get_preset_archive_database()->get_selected_repositories_uuid());
// The CallAfter is needed as well, without it, GL extensions did not show.
// Also, we only want to show this when the wizard does not, so the new user
// sees something else than "we want something" on the first start.
@ -949,6 +950,71 @@ void GUI_App::init_app_config()
}
}
void GUI_App::legacy_app_config_vendor_check()
{
// Expected state:
// User runs 2.8.0+ for the first time. They have Prusa SLA printers installed.
// Prusa SLA printers moved from PrusaResearch.ini to PrusaResearchSLA.ini
// We expect this is detected and fixed on the first run, when PrusaResearchSLA is not installed yet.
// Steps:
// Move the printers in appconfig to PrusaResearchSLA
// Moving the printers is not enough. The new ini PrusaResearchSLA needs to be installed.
// But we cannot install bundles without preset updater.
// So we just move it to the vendor folder. Since all profiles are named the same, it should not be a problem.
// Preset updater should be doing blocking update over PrusaResearch.ini. Then all should be ok.
const std::vector<std::string> prusaslicer_moved_to_sla = { "SL1", "SL1S" };
const std::map<std::string, std::map<std::string, std::set<std::string>>>& vendor_map = app_config->vendors();
bool found_legacy_printers = false;
if (const auto& vendor_it = vendor_map.find("PrusaResearch"); vendor_it != vendor_map.end()) {
for (const std::string& model : prusaslicer_moved_to_sla) {
if (const auto& it = vendor_it->second.find(model); it != vendor_it->second.end()) {
BOOST_LOG_TRIVIAL(error) << "found " << model;
found_legacy_printers = true;
break;
}
}
}
if (!found_legacy_printers) {
return;
}
bool found_prusa_sla_vendor = vendor_map.find("PrusaResearchSLA") != vendor_map.end();
// make a deep copy of vendor map with moved printers
std::map<std::string, std::map<std::string, std::set<std::string>>> new_vendor_map;
for (const auto& vendor : vendor_map) {
for (const auto& model : vendor.second) {
if (vendor.first == "PrusaResearch" && std::find(prusaslicer_moved_to_sla.begin(), prusaslicer_moved_to_sla.end(), model.first) != prusaslicer_moved_to_sla.end()) {
for (const std::string& variant : model.second) {
new_vendor_map["PrusaResearchSLA"][model.first].emplace(variant);
}
} else {
for (const std::string& variant : model.second) {
new_vendor_map[vendor.first][model.first].emplace(variant);
}
}
}
}
app_config->set_vendors(new_vendor_map);
if (found_prusa_sla_vendor) {
// The vendor was present in appconfig, we do nothing with its ini file.
return;
}
// copy PrusaResearchSLA ini file to vendors
const boost::filesystem::path prusa_sla_in_resources = boost::filesystem::path(Slic3r::resources_dir()) / "profiles" / "PrusaResearchSLA.ini";
assert(boost::filesystem::exists(prusa_sla_in_resources));
const boost::filesystem::path prusa_sla_in_vendors = boost::filesystem::path(Slic3r::data_dir()) / "vendor" / "PrusaResearchSLA.ini";
if (boost::filesystem::exists(prusa_sla_in_vendors)) {
return;
}
std::string message;
CopyFileResult cfr = copy_file(prusa_sla_in_resources.string(), prusa_sla_in_vendors.string(), message, false);
if (cfr != SUCCESS) {
BOOST_LOG_TRIVIAL(error) << "Failed to copy file " << prusa_sla_in_resources << " to " << prusa_sla_in_vendors << ": " << message;
}
}
// returns old config path to copy from if such exists,
// returns an empty string if such config path does not exists or if it cannot be loaded.
std::string GUI_App::check_older_app_config(Semver current_version, bool backup)
@ -1384,6 +1450,9 @@ bool GUI_App::on_init_inner()
if (is_editor())
mainframe->select_tab(size_t(0));
// Call this check only after appconfig was loaded to mainframe, otherwise there will be duplicity error.
legacy_app_config_vendor_check();
sidebar().obj_list()->init_objects(); // propagate model objects to object list
update_mode(); // mode sizer doesn't exist anymore, so we came update mode here, before load_current_presets
SetTopWindow(mainframe);
@ -3156,10 +3225,6 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage
// Destructor does not call Destroy.
m_login_dialog.reset();
}
// Update archive db if login status changed, otherwise we expect to have archive db on date.
if (user_was_logged != plater()->get_user_account()->is_logged()) {
plater()->get_preset_archive_database()->sync_blocking();
}
#endif // 0
plater()->get_preset_archive_database()->set_wizard_lock(true);
plater()->get_preset_archive_database()->sync_blocking();
@ -3394,6 +3459,19 @@ void GUI_App::manage_updates()
bool GUI_App::check_updates(const bool verbose)
{
// verbose means - not run after startup, but by user
if (verbose) {
// do preset_updater sync so if user runs slicer for a long time, check for updates actually delivers updates.
// for preset_updater sync we need to sync archive database first
plater()->get_preset_archive_database()->sync_blocking();
// and we can have user to select the repos they want (thats additional dialog)
manage_updates();
// then its time for preset_updater sync
// BE CAREFUL! sync and sync_blocking sends event that calls check_updates(false)
preset_updater->sync_blocking(preset_bundle, this, plater()->get_preset_archive_database()->get_archive_repositories(), plater()->get_preset_archive_database()->get_selected_repositories_uuid());
// and then we check updates
}
PresetUpdater::UpdateResult updater_result;
try {
preset_updater->update_index_db();

View File

@ -434,6 +434,7 @@ private:
// returns old config path to copy from if such exists,
// returns an empty string if such config path does not exists or if it cannot be loaded.
std::string check_older_app_config(Semver current_version, bool backup);
void legacy_app_config_vendor_check();
void window_pos_save(wxTopLevelWindow* window, const std::string &name);
void window_pos_restore(wxTopLevelWindow* window, const std::string &name, bool default_maximized = false);
void window_pos_sanitize(wxTopLevelWindow* window);

View File

@ -616,13 +616,22 @@ void PresetArchiveDatabase::read_server_manifest(const std::string& json_body)
save_app_manifest_json();
}
bool PresetArchiveDatabase::is_selected_archive(const std::string& uuid) const
bool PresetArchiveDatabase::is_selected_repository_by_uuid(const std::string& uuid) const
{
auto selected_it = m_selected_repositories_uuid.find(uuid);
assert(selected_it != m_selected_repositories_uuid.end());
return selected_it->second;
}
bool PresetArchiveDatabase::is_selected_repository_by_id(const std::string& repo_id) const
{
assert(!repo_id.empty());
for (const auto& repo_ptr : m_archive_repositories) {
if (repo_ptr->get_manifest().id == repo_id) {
return true;
}
}
return false;
}
void PresetArchiveDatabase::consolidate_selected_uuids_map()
{
//std::vector<std::unique_ptr<const ArchiveRepository>> m_archive_repositories;
@ -681,6 +690,7 @@ void PresetArchiveDatabase::sync_blocking()
{
if (m_wizard_lock) {
m_staged_sync = true;
return;
}
std::string manifest;
if (!sync_inner(m_token, manifest))
@ -690,7 +700,7 @@ void PresetArchiveDatabase::sync_blocking()
void PresetArchiveDatabase::set_wizard_lock(bool lock)
{
m_wizard_lock = lock;
m_wizard_lock = lock;
if (m_staged_sync) {
sync_blocking();
}

View File

@ -106,7 +106,8 @@ public:
void sync_blocking();
//void set_local_archives(AppConfig* app_config);
void read_server_manifest(const std::string& json_body);
bool is_selected_archive(const std::string& uuid) const;
bool is_selected_repository_by_uuid(const std::string& uuid) const;
bool is_selected_repository_by_id(const std::string& repo_id) const;
const std::map<std::string, bool>& get_selected_repositories_uuid() const { assert(m_selected_repositories_uuid.size() == m_archive_repositories.size()); return m_selected_repositories_uuid; }
bool set_selected_repositories(const std::vector<std::string>& used_uuids, std::string& msg);
std::string add_local_archive(const boost::filesystem::path path, std::string& msg);

View File

@ -64,7 +64,7 @@ void UIManager::fill_entries(bool init_selection/* = false*/)
const ArchiveRepositoryVector& archs = m_pad->get_archive_repositories();
for (const auto& archive : archs) {
const std::string& uuid = archive->get_uuid();
if (init_selection && m_pad->is_selected_archive(uuid))
if (init_selection && m_pad->is_selected_repository_by_uuid(uuid))
m_selected_uuids.emplace(uuid);
const bool is_selected = m_selected_uuids.find(uuid) != m_selected_uuids.end();

View File

@ -186,6 +186,7 @@ struct PresetUpdater::priv
void set_download_prefs(const AppConfig *app_config);
//bool get_file(const std::string &url, const fs::path &target_path) const;
void prune_tmps() const;
void clear_cache_vendor() const;
void sync_config(const VendorMap& vendors, const GUI::ArchiveRepository& archive);
void check_install_indices() const;
@ -272,6 +273,18 @@ void PresetUpdater::priv::prune_tmps() const
fs::remove(dir_entry.path());
}
}
// Remove all files in cache/vendor
void PresetUpdater::priv::clear_cache_vendor() const
{
boost::system::error_code ec;
for (auto& dir_entry : boost::filesystem::directory_iterator(cache_vendor_path)) {
fs::remove(dir_entry.path(), ec);
if (ec) {
BOOST_LOG_TRIVIAL(error) << "Failed to remove " << dir_entry << " during cache cleanup. Reason: " << ec.what();
ec.clear();
}
}
}
// gets resource to cache/<vendor_name>/
void PresetUpdater::priv::get_missing_resource(const GUI::ArchiveRepository& archive, const std::string& vendor, const std::string& filename, const std::string& repository_id_from_ini) const
@ -1148,6 +1161,7 @@ void PresetUpdater::sync(const PresetBundle *preset_bundle, wxEvtHandler* evt_ha
if (!p->enabled_config_update) { return; }
p->thread = std::thread([this, &vendors = preset_bundle->vendors, &repositories, &selected_repo_uuids, evt_handler]() {
this->p->clear_cache_vendor();
this->p->prune_tmps();
for(const auto& archive : repositories) {
auto it = selected_repo_uuids.find(archive->get_uuid());
@ -1177,6 +1191,7 @@ void PresetUpdater::sync_blocking(const PresetBundle* preset_bundle, wxEvtHandle
p->set_download_prefs(GUI::wxGetApp().app_config);
if (!p->enabled_config_update) { return; }
this->p->clear_cache_vendor();
this->p->prune_tmps();
for (const auto& archive : repositories) {
auto it = selected_repo_uuids.find(archive->get_uuid());