Merge branch 'dk_updater_fix'

This commit is contained in:
David Kocik 2023-01-19 13:45:04 +01:00
commit 6d37c505f7
5 changed files with 33 additions and 19 deletions

View File

@ -811,13 +811,14 @@ void GUI_App::post_init()
// preset_updater->sync downloads profile updates on background so it must begin after config wizard finished.
bool cw_showed = this->config_wizard_startup();
this->preset_updater->sync(preset_bundle);
this->app_version_check(false);
if (! cw_showed) {
// 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.
show_send_system_info_dialog_if_needed();
}
show_send_system_info_dialog_if_needed();
}
// app version check is asynchronous and triggers blocking dialog window, better call it last
this->app_version_check(false);
});
}
@ -1245,7 +1246,7 @@ bool GUI_App::on_init_inner()
preset_updater = new PresetUpdater();
Bind(EVT_SLIC3R_VERSION_ONLINE, &GUI_App::on_version_read, this);
Bind(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE, [this](const wxCommandEvent& evt) {
if (this->plater_ != nullptr && app_config->get("notify_release") == "all") {
if (this->plater_ != nullptr && (m_app_updater->get_triggered_by_user() || app_config->get("notify_release") == "all")) {
std::string evt_string = into_u8(evt.GetString());
if (*Semver::parse(SLIC3R_VERSION) < *Semver::parse(evt_string)) {
auto notif_type = (evt_string.find("beta") != std::string::npos ? NotificationType::NewBetaAvailable : NotificationType::NewAlphaAvailable);
@ -3305,7 +3306,8 @@ void GUI_App::on_version_read(wxCommandEvent& evt)
app_config->set("version_online", into_u8(evt.GetString()));
app_config->save();
std::string opt = app_config->get("notify_release");
if (this->plater_ == nullptr || (opt != "all" && opt != "release")) {
if (this->plater_ == nullptr || (!m_app_updater->get_triggered_by_user() && opt != "all" && opt != "release")) {
BOOST_LOG_TRIVIAL(info) << "Version online: " << evt.GetString() << ". User does not wish to be notified.";
return;
}
if (*Semver::parse(SLIC3R_VERSION) >= *Semver::parse(into_u8(evt.GetString()))) {
@ -3355,7 +3357,7 @@ void GUI_App::app_updater(bool from_user)
assert(!app_data.target_path.empty());
// dialog with new version info
AppUpdateAvailableDialog dialog(*Semver::parse(SLIC3R_VERSION), *app_data.version);
AppUpdateAvailableDialog dialog(*Semver::parse(SLIC3R_VERSION), *app_data.version, from_user);
auto dialog_result = dialog.ShowModal();
// checkbox "do not show again"
if (dialog.disable_version_check()) {

View File

@ -89,6 +89,13 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin
m_custom_toolbar_size = atoi(get_app_config()->get("custom_toolbar_size").c_str());
m_use_custom_toolbar_size = get_app_config()->get("use_custom_toolbar_size") == "1";
// set Field for notify_release to its value
if (m_optgroup_gui && m_optgroup_gui->get_field("notify_release") != nullptr) {
boost::any val = s_keys_map_NotifyReleaseMode.at(wxGetApp().app_config->get("notify_release"));
m_optgroup_gui->get_field("notify_release")->set_value(val, false);
}
if (wxGetApp().is_editor()) {
auto app_config = get_app_config();

View File

@ -93,7 +93,7 @@ bool MsgUpdateSlic3r::disable_version_check() const
wxSize AppUpdateAvailableDialog::AUAD_size;
// AppUpdater
AppUpdateAvailableDialog::AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online)
AppUpdateAvailableDialog::AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online, bool from_user)
: MsgDialog(nullptr, _(L("App Update available")), wxString::Format(_(L("New version of %s is available.\nDo you wish to download it?")), SLIC3R_APP_NAME))
{
auto* versions = new wxFlexGridSizer(1, 0, VERT_SPACING);
@ -104,8 +104,10 @@ AppUpdateAvailableDialog::AppUpdateAvailableDialog(const Semver& ver_current, co
content_sizer->Add(versions);
content_sizer->AddSpacer(VERT_SPACING);
cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new releases any more")));
content_sizer->Add(cbox);
if(!from_user) {
cbox = new wxCheckBox(this, wxID_ANY, _(L("Don't notify about new releases any more")));
content_sizer->Add(cbox);
}
content_sizer->AddSpacer(VERT_SPACING);
AUAD_size = content_sizer->GetSize();
@ -125,6 +127,8 @@ AppUpdateAvailableDialog::~AppUpdateAvailableDialog() {}
bool AppUpdateAvailableDialog::disable_version_check() const
{
if (!cbox)
return false;
return cbox->GetValue();
}

View File

@ -42,7 +42,7 @@ private:
class AppUpdateAvailableDialog : public MsgDialog
{
public:
AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online);
AppUpdateAvailableDialog(const Semver& ver_current, const Semver& ver_online, bool from_user);
AppUpdateAvailableDialog(AppUpdateAvailableDialog&&) = delete;
AppUpdateAvailableDialog(const AppUpdateAvailableDialog&) = delete;
AppUpdateAvailableDialog& operator=(AppUpdateAvailableDialog&&) = delete;
@ -53,7 +53,7 @@ public:
bool disable_version_check() const;
static wxSize AUAD_size;
private:
wxCheckBox* cbox;
wxCheckBox* cbox {nullptr};
};
class AppUpdateDownloadDialog : public MsgDialog

View File

@ -221,7 +221,7 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
}
// progress event
size_t gui_progress = progress.dltotal > 0 ? 100 * progress.dlnow / progress.dltotal : 0;
BOOST_LOG_TRIVIAL(error) << "App download " << gui_progress << "% " << progress.dlnow << " of " << progress.dltotal;
BOOST_LOG_TRIVIAL(debug) << "App download " << gui_progress << "% " << progress.dlnow << " of " << progress.dltotal;
if (last_gui_progress < gui_progress && (last_gui_progress != 0 || gui_progress != 100)) {
last_gui_progress = gui_progress;
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_APP_DOWNLOAD_PROGRESS);
@ -243,14 +243,15 @@ boost::filesystem::path AppUpdater::priv::download_file(const DownloadAppData& d
tmp_path += format(".%1%%2%", get_current_pid(), ".download");
try
{
boost::nowide::fstream file(tmp_path.string(), std::ios::out | std::ios::binary | std::ios::trunc);
file.write(body.c_str(), body.size());
file.close();
FILE* file;
file = fopen(tmp_path.string().c_str(), "wb");
fwrite(body.c_str(), 1, body.size(), file);
fclose(file);
boost::filesystem::rename(tmp_path, dest_path);
}
catch (const std::exception&)
catch (const std::exception& e)
{
error_message = GUI::format("Failed to write and move %1% to %2%", tmp_path, dest_path);
error_message = GUI::format("Failed to write and move %1% to %2%:/n%3%", tmp_path, dest_path, e.what());
return false;
}
return true;
@ -363,10 +364,10 @@ void AppUpdater::priv::parse_version_string(const std::string& body)
if (data.first == "url") {
new_data.url = data.second.data();
new_data.target_path = m_default_dest_folder / AppUpdater::get_filename_from_url(new_data.url);
BOOST_LOG_TRIVIAL(error) << format("parsing version string: url: %1%", new_data.url);
BOOST_LOG_TRIVIAL(info) << format("parsing version string: url: %1%", new_data.url);
} else if (data.first == "size"){
new_data.size = std::stoi(data.second.data());
BOOST_LOG_TRIVIAL(error) << format("parsing version string: expected size: %1%", new_data.size);
BOOST_LOG_TRIVIAL(info) << format("parsing version string: expected size: %1%", new_data.size);
}
}
}