FIX: export and import configs issue

Jira: XXXX
import config lose xxx_settings_id issue
export process config should not have user printer
export process config shoule remove duplicate presets
export filamnent config: filament list should have no third print compatible presets

Change-Id: I94bac062e07b3a989ff86142e3fb8266a48364c6
This commit is contained in:
maosheng.wei
2023-10-31 18:17:41 +08:00
committed by Lane.Wei
parent 7ffbb7d014
commit 5f0dc7faed
4 changed files with 55 additions and 10 deletions

View File

@@ -2126,11 +2126,11 @@ bool PresetCollection::clone_presets(std::vector<Preset const *> const &presets,
}
preset.file = this->path_for_preset(preset);
if (m_type == Preset::TYPE_PRINT)
preset.config.option<ConfigOptionString>("print_settings_id", true)->value.clear();
preset.config.option<ConfigOptionString>("print_settings_id", true)->value = preset.name;
else if (m_type == Preset::TYPE_FILAMENT)
preset.config.option<ConfigOptionStrings>("filament_settings_id", true)->values[0].clear();
preset.config.option<ConfigOptionStrings>("filament_settings_id", true)->values[0] = preset.name;
else if (m_type == Preset::TYPE_PRINTER)
preset.config.option<ConfigOptionString>("printer_settings_id", true)->value.clear();
preset.config.option<ConfigOptionString>("printer_settings_id", true)->value = preset.name;
}
if (!failures.empty() && !force_rewritten)
return false;
@@ -2245,11 +2245,11 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
//BBS: add lock logic for sync preset in background
if (m_type == Preset::TYPE_PRINT)
preset.config.option<ConfigOptionString>("print_settings_id", true)->value.clear();
preset.config.option<ConfigOptionString>("print_settings_id", true)->value = new_name;
else if (m_type == Preset::TYPE_FILAMENT)
preset.config.option<ConfigOptionStrings>("filament_settings_id", true)->values[0].clear();
preset.config.option<ConfigOptionStrings>("filament_settings_id", true)->values[0] = new_name;
else if (m_type == Preset::TYPE_PRINTER)
preset.config.option<ConfigOptionString>("printer_settings_id", true)->value.clear();
preset.config.option<ConfigOptionString>("printer_settings_id", true)->value = new_name;
final_inherits = preset.inherits();
unlock();
// TODO: apply change from custom root to devided presets.
@@ -2293,11 +2293,11 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
else
preset.is_project_embedded = false;
if (m_type == Preset::TYPE_PRINT)
preset.config.option<ConfigOptionString>("print_settings_id", true)->value.clear();
preset.config.option<ConfigOptionString>("print_settings_id", true)->value = new_name;
else if (m_type == Preset::TYPE_FILAMENT)
preset.config.option<ConfigOptionStrings>("filament_settings_id", true)->values[0].clear();
preset.config.option<ConfigOptionStrings>("filament_settings_id", true)->values[0] = new_name;
else if (m_type == Preset::TYPE_PRINTER)
preset.config.option<ConfigOptionString>("printer_settings_id", true)->value.clear();
preset.config.option<ConfigOptionString>("printer_settings_id", true)->value = new_name;
//BBS: add lock logic for sync preset in background
final_inherits = inherits;
unlock();

View File

@@ -707,7 +707,7 @@ PresetsConfigSubstitutions PresetBundle::import_presets(std::vector<std::string>
// create target file path
std::string target_file_path = boost::filesystem::path(temp_folder / file_name).make_preferred().string();
status = mz_zip_reader_extract_to_file(&zip_archive, i, target_file_path.c_str(), MZ_ZIP_FLAG_CASE_SENSITIVE);
status = mz_zip_reader_extract_to_file(&zip_archive, i, encode_path(target_file_path.c_str()).c_str(), MZ_ZIP_FLAG_CASE_SENSITIVE);
// target file is opened
if (MZ_FALSE == status) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " Failed to open target file: " << target_file_path;