ENH: Limit the size of uploaded cloud files
Jira: no-jira Change-Id: Id8890f4194e56e3c6172fe1c6a065e3a7a7469b9
This commit is contained in:
parent
30bad38fb9
commit
96c23f743c
|
@ -1329,6 +1329,14 @@ int PresetCollection::get_differed_values_to_update(Preset& preset, std::map<std
|
|||
<< " and base_id is: " << preset.base_id;
|
||||
key_values[BBL_JSON_KEY_UPDATE_TIME] = std::to_string(preset.updated_time);
|
||||
key_values[BBL_JSON_KEY_TYPE] = Preset::get_iot_type_string(preset.type);
|
||||
|
||||
int update_size = 0;
|
||||
for (const auto &pair : key_values) {
|
||||
update_size += pair.first.size();
|
||||
update_size += pair.second.size();
|
||||
}
|
||||
if (update_size > 350 * 1024) return -2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -4947,7 +4947,7 @@ void GUI_App::sync_preset(Preset* preset)
|
|||
}
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(trace) << "[sync_preset]init: can not generate differed key-values";
|
||||
BOOST_LOG_TRIVIAL(info) << "[sync_preset]init: can not generate differed key-values and code: " << ret;
|
||||
result = 0;
|
||||
updated_info = "hold";
|
||||
}
|
||||
|
@ -4977,7 +4977,11 @@ void GUI_App::sync_preset(Preset* preset)
|
|||
}
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(trace) << "[sync_preset]create: can not generate differed preset";
|
||||
BOOST_LOG_TRIVIAL(info) << "[sync_preset]create: can not generate differed preset and code: " << ret;
|
||||
if (ret == -2) {
|
||||
result = 0;
|
||||
updated_info = "hold";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (preset->sync_info.compare("update") == 0) {
|
||||
|
@ -5004,8 +5008,9 @@ void GUI_App::sync_preset(Preset* preset)
|
|||
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(trace) << "[sync_preset]update: can not generate differed key-values, we need to skip this preset "<< preset->name;
|
||||
BOOST_LOG_TRIVIAL(info) << "[sync_preset]update: can not generate differed key-values, we need to skip this preset " << preset->name << " code: " << ret;
|
||||
result = 0;
|
||||
if (ret == -2) updated_info = "hold";
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1868,6 +1868,15 @@ void Tab::update_preset_description_line()
|
|||
m_parent->Layout();
|
||||
}
|
||||
|
||||
static void validate_custom_note_cb(Tab *tab, ConfigOptionsGroupShp opt_group, const t_config_option_key &opt_key, const boost::any &value)
|
||||
{
|
||||
if (boost::any_cast<std::string>(value).size() > 40 * 1024) {
|
||||
MessageDialog dialog(static_cast<wxWindow *>(wxGetApp().mainframe), _L("The notes are too large, and may not be synchronized to the cloud. Please keep it within 40k."),
|
||||
"", wxICON_WARNING | wxOK);
|
||||
dialog.ShowModal();
|
||||
}
|
||||
}
|
||||
|
||||
void Tab::update_frequently_changed_parameters()
|
||||
{
|
||||
const bool is_fff = supports_printer_technology(ptFFF);
|
||||
|
@ -2159,6 +2168,7 @@ void TabPrint::build()
|
|||
option.opt.is_code = true;
|
||||
option.opt.height = 15;
|
||||
optgroup->append_single_option_line(option);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key &opt_key, const boost::any &value) { validate_custom_note_cb(this, optgroup, opt_key, value); };
|
||||
|
||||
optgroup = page->new_optgroup(L("Notes"),"note");
|
||||
optgroup->label_width = 0;
|
||||
|
@ -2166,6 +2176,7 @@ void TabPrint::build()
|
|||
option.opt.full_width = true;
|
||||
option.opt.height = 25;
|
||||
optgroup->append_single_option_line(option);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key &opt_key, const boost::any &value) { validate_custom_note_cb(this, optgroup, opt_key, value); };
|
||||
|
||||
#if 0
|
||||
//page = add_options_page(L("Dependencies"), "advanced.png");
|
||||
|
@ -2848,6 +2859,10 @@ static void validate_custom_gcode_cb(Tab* tab, ConfigOptionsGroupShp opt_group,
|
|||
tab->validate_custom_gcodes_was_shown = !Tab::validate_custom_gcode(opt_group->title, boost::any_cast<std::string>(value));
|
||||
tab->update_dirty();
|
||||
tab->on_value_change(opt_key, value);
|
||||
if (boost::any_cast<std::string>(value).size() > 40 * 1024) {
|
||||
MessageDialog dialog(static_cast<wxWindow *>(wxGetApp().mainframe), _L("Custom G-code files are too large, and may not be synchronized to the cloud. Please keep it within 40k."), "", wxICON_WARNING | wxOK);
|
||||
dialog.ShowModal();
|
||||
}
|
||||
}
|
||||
|
||||
void TabFilament::add_filament_overrides_page()
|
||||
|
@ -3168,6 +3183,7 @@ void TabFilament::build()
|
|||
option.opt.full_width = true;
|
||||
option.opt.height = notes_field_height;
|
||||
optgroup->append_single_option_line(option);
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key &opt_key, const boost::any &value) { validate_custom_note_cb(this, optgroup, opt_key, value); };
|
||||
|
||||
//BBS
|
||||
#if 0
|
||||
|
@ -3607,7 +3623,7 @@ void TabPrinter::build_fff()
|
|||
option.opt.full_width = true;
|
||||
option.opt.height = notes_field_height;
|
||||
optgroup->append_single_option_line(option);
|
||||
|
||||
optgroup->m_on_change = [this, optgroup](const t_config_option_key &opt_key, const boost::any &value) { validate_custom_note_cb(this, optgroup, opt_key, value); };
|
||||
|
||||
build_unregular_pages(true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue