Start updater during start of prusaslicer.
Don't search the directory if only verifying that a file exists
is sufficient.
This commit is contained in:
Vojtech Bubnik 2021-11-19 15:48:03 +01:00
parent 56f409921c
commit 6ebee079c9

View File

@ -431,14 +431,12 @@ bool static check_old_linux_datadir(const wxString& app_name) {
static bool run_updater_win() static bool run_updater_win()
{ {
// find updater exe // find updater exe
boost::filesystem::path path_to_binary = boost::dll::program_location(); boost::filesystem::path path_updater = boost::dll::program_location().parent_path() / "prusaslicer-updater.exe";
for (const auto& dir_entry : boost::filesystem::directory_iterator(path_to_binary.parent_path())) { if (boost::filesystem::exists(path_updater)) {
if (dir_entry.path().filename() == "prusaslicer-updater.exe") {
// run updater. Original args: /silent -restartapp prusa-slicer.exe -startappfirst // run updater. Original args: /silent -restartapp prusa-slicer.exe -startappfirst
// Using quoted string as mentioned in CreateProcessW docs. // Using quoted string as mentioned in CreateProcessW docs, silent execution parameter.
std::wstring wcmd = L"\"" + dir_entry.path().wstring() + L"\""; std::wstring wcmd = L"\"" + path_updater.wstring() + L"\" /silent";
wcmd += L" /silent";
// additional information // additional information
STARTUPINFOW si; STARTUPINFOW si;
@ -468,15 +466,11 @@ static bool run_updater_win()
} else { } else {
BOOST_LOG_TRIVIAL(error) << "Failed to start prusaslicer-updater.exe with command " << wcmd; BOOST_LOG_TRIVIAL(error) << "Failed to start prusaslicer-updater.exe with command " << wcmd;
} }
break;
}
} }
return false; return false;
} }
#endif //_WIN32 #endif //_WIN32
wxString file_wildcards(FileType file_type, const std::string &custom_extension) wxString file_wildcards(FileType file_type, const std::string &custom_extension)
{ {
static const std::string defaults[FT_SIZE] = { static const std::string defaults[FT_SIZE] = {
@ -738,14 +732,11 @@ void GUI_App::post_init()
// sees something else than "we want something" on the first start. // 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();
} }
bool updater_running =
#ifdef _WIN32 #ifdef _WIN32
// Run external updater on Windows. // Run external updater on Windows.
run_updater_win(); if (! run_updater_win())
#else // "prusaslicer-updater.exe" was not started, run our own update check.
false;
#endif // _WIN32 #endif // _WIN32
if (!updater_running)
this->preset_updater->slic3r_update_notify(); this->preset_updater->slic3r_update_notify();
}); });
} }