Fix: add the preset auto-copy logic at bootup

sometimes the installed profiles are deleted by the installer/uninstaller
add the auto-copy logic to make sure it is there after bootup

Change-Id: I2e7c9eb7576672377c0f08575d17c775282f4671
This commit is contained in:
lane.wei 2022-10-18 14:43:52 +08:00 committed by Lane.Wei
parent 97c6573a75
commit f3a5a50199
1 changed files with 20 additions and 8 deletions

View File

@ -871,6 +871,9 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
{
BOOST_LOG_TRIVIAL(info) << "[BBL Updater]:Checking whether the profile from resource is newer";
AppConfig *app_config = GUI::wxGetApp().app_config;
const auto enabled_vendors = app_config->vendors();
//BBS: refine the init check logic
std::vector<std::string> bundles;
for (auto &dir_entry : boost::filesystem::directory_iterator(rsrc_path)) {
@ -883,6 +886,7 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
vendor_name.erase(vendor_name.size() - 5);
if (enabled_config_update) {
if ( fs::exists(path_in_vendor)) {
if (enabled_vendors.find(vendor_name) != enabled_vendors.end()) {
Semver resource_ver = get_version_from_json(file_path);
Semver vendor_ver = get_version_from_json(path_in_vendor.string());
@ -893,11 +897,19 @@ void PresetUpdater::priv::check_installed_vendor_profiles() const
bundles.push_back(vendor_name);
}
}
else if (vendor_name == PresetBundle::BBL_BUNDLE) {//if vendor has no file, copy it from resource for BBL
else {
//need to be removed because not installed
fs::remove(path_in_vendor);
const auto path_of_vendor = vendor_path / vendor_name;
if (fs::exists(path_of_vendor))
fs::remove_all(path_of_vendor);
}
}
else if ((vendor_name == PresetBundle::BBL_BUNDLE) || (enabled_vendors.find(vendor_name) != enabled_vendors.end())) {//if vendor has no file, copy it from resource for BBL
bundles.push_back(vendor_name);
}
}
else if (vendor_name == PresetBundle::BBL_BUNDLE) {//always update configs from resource to vendor for BBL
else if ((vendor_name == PresetBundle::BBL_BUNDLE) || (enabled_vendors.find(vendor_name) != enabled_vendors.end())) { //always update configs from resource to vendor for BBL
bundles.push_back(vendor_name);
}
}