mirror of
https://github.com/microsoft/PowerToys
synced 2025-09-01 06:55:17 +00:00
[Auto-update] Auto-update improvements (#11356)
* [Updating] Refactor autoupdate mechanism to use Settings window buttons * [Updating] Don't use underscores in update_state (#11029) * [Updating] Rename action_runner to be consisent with accepted format * [Updating] Make UpdateState values explicit * [Setup] Set default bootstrapper log severity to debug * [BugReport] Include all found bootstrapper logs * [Setup] Use capital letter for ActionRunner * [Updating] Simple UI to test UpdateState * [Action Runner] cleanup and coding style * [BugReportTool] fix coding convension * [Auto-update][PT Settings] Updated general page in the Settings (#11227) * [Auto-update][PT Settings] File watcher monitoring UpdateState.json (#11282) * Handle button clicks (#11288) * [Updating] Document ActionRunner cmd flags * [Auto-update][PT Settings] Updated UI (#11335) * [Updating] Do not reset update state when msi cancellation detected * [Updating] Directly launch update_now PT action instead of using custom URI scheme * Checking for updates UI (#11354) * [Updating] Fix cannotDownload state in action runner * [Updating] Reset update state to CannotDownload if action runner encountered an error * [Updating][PT Settings] downloading label, disable button in error state * Changed error message * [Updating rename CannotDownload to ErrorDownloading * [Updating] Add trace logging for Check for updates callback * [Updating][PT Settings] simplify downloading checks * [Updating][PT Settings] Updated text labels * [Updating][PT Settings] Retry to load settings if failed * [Updating][PT Settings] Text fix * [Updating][PT Settings] Installed version links removed * [Updating][PT Settings] Error text updated * [Updating][PT Settings] Show label after version checked * [Updating][PT Settings] Text foreground fix * [Updating][PT Settings] Clean up * [Updating] Do not reset releasePageUrl in case of error/cancellation * [Updating][PT Settings] fixed missing string * [Updating][PT Settings] checked for updates state fix Co-authored-by: yuyoyuppe <a.yuyoyuppe@gmail.com> Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com> Co-authored-by: Enrico Giordani <enrico.giordani@gmail.com>
This commit is contained in:
@@ -8,9 +8,7 @@
|
||||
#include <common/interop/two_way_pipe_message_ipc.h>
|
||||
#include "tray_icon.h"
|
||||
#include "general_settings.h"
|
||||
#include <common/themes/windows_colors.h>
|
||||
#include "restart_elevated.h"
|
||||
#include "update_state.h"
|
||||
#include "update_utils.h"
|
||||
#include "centralized_kb_hook.h"
|
||||
|
||||
@@ -23,6 +21,8 @@
|
||||
#include <common/utils/process_path.h>
|
||||
#include <common/utils/timeutil.h>
|
||||
#include <common/utils/winapi_error.h>
|
||||
#include <common/updating/updateState.h>
|
||||
#include <common/themes/windows_colors.h>
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
@@ -84,34 +84,16 @@ std::optional<std::wstring> dispatch_json_action_to_module(const json::JsonObjec
|
||||
}
|
||||
else if (action == L"check_for_updates")
|
||||
{
|
||||
if (auto update_check_result = check_for_updates())
|
||||
{
|
||||
VersionHelper latestVersion{ VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION };
|
||||
bool isVersionLatest = true;
|
||||
if (auto new_version = std::get_if<updating::new_version_download_info>(&*update_check_result))
|
||||
{
|
||||
latestVersion = new_version->version;
|
||||
isVersionLatest = false;
|
||||
}
|
||||
json::JsonObject json;
|
||||
json.SetNamedValue(L"version", json::value(latestVersion.toWstring()));
|
||||
json.SetNamedValue(L"isVersionLatest", json::value(isVersionLatest));
|
||||
|
||||
result.emplace(json.Stringify());
|
||||
|
||||
UpdateState::store([](UpdateState& state) {
|
||||
state.github_update_last_checked_date.emplace(timeutil::now());
|
||||
});
|
||||
}
|
||||
check_for_updates_settings_callback();
|
||||
}
|
||||
else if (action == L"request_update_state_date")
|
||||
{
|
||||
json::JsonObject json;
|
||||
|
||||
auto update_state = UpdateState::read();
|
||||
if (update_state.github_update_last_checked_date)
|
||||
if (update_state.githubUpdateLastCheckedDate)
|
||||
{
|
||||
const time_t date = *update_state.github_update_last_checked_date;
|
||||
const time_t date = *update_state.githubUpdateLastCheckedDate;
|
||||
json.SetNamedValue(L"updateStateDate", json::value(std::to_wstring(date)));
|
||||
}
|
||||
|
||||
@@ -336,7 +318,7 @@ void run_settings_window(bool showOobeWindow)
|
||||
// Arg 6: elevated status
|
||||
bool isElevated{ get_general_settings().isElevated };
|
||||
std::wstring settings_elevatedStatus = isElevated ? L"true" : L"false";
|
||||
|
||||
|
||||
// Arg 7: is user an admin
|
||||
bool isAdmin{ get_general_settings().isAdmin };
|
||||
std::wstring settings_isUserAnAdmin = isAdmin ? L"true" : L"false";
|
||||
@@ -364,14 +346,14 @@ void run_settings_window(bool showOobeWindow)
|
||||
executable_args.append(settings_isUserAnAdmin);
|
||||
executable_args.append(L" ");
|
||||
executable_args.append(settings_showOobe);
|
||||
|
||||
|
||||
BOOL process_created = false;
|
||||
|
||||
if (is_process_elevated())
|
||||
{
|
||||
// TODO: Revisit this after switching to .NET 5
|
||||
// Due to a bug in .NET, running the Settings process as non-elevated
|
||||
// from an elevated process sometimes results in a crash.
|
||||
// from an elevated process sometimes results in a crash.
|
||||
// process_created = run_settings_non_elevated(executable_path.c_str(), executable_args.data(), &process_info);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user