mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
refactor(updating): update async methods to use std::expected and co_await
This commit is contained in:
@@ -173,7 +173,9 @@ void ProcessNewVersionInfo(const github_version_info& version_info,
|
||||
// Cleanup old updates before downloading the latest
|
||||
updating::cleanup_updates();
|
||||
|
||||
if (download_new_version(new_version_info))
|
||||
std::optional<std::filesystem::path> downloaded_installer;
|
||||
download_new_version(new_version_info, downloaded_installer).get();
|
||||
if (downloaded_installer)
|
||||
{
|
||||
state.state = UpdateState::readyToInstall;
|
||||
state.downloadedInstallerFilename = new_version_info.installer_filename;
|
||||
@@ -232,7 +234,12 @@ void PeriodicUpdateWorker()
|
||||
bool version_info_obtained = false;
|
||||
try
|
||||
{
|
||||
const auto new_version_info = get_github_version_info_async();
|
||||
#if USE_STD_EXPECTED
|
||||
std::expected<github_version_info, std::wstring> new_version_info;
|
||||
#else
|
||||
nonstd::expected<github_version_info, std::wstring> new_version_info;
|
||||
#endif
|
||||
get_github_version_info_async(false, new_version_info).get();
|
||||
if (new_version_info.has_value())
|
||||
{
|
||||
version_info_obtained = true;
|
||||
@@ -272,7 +279,12 @@ void CheckForUpdatesCallback()
|
||||
auto state = UpdateState::read();
|
||||
try
|
||||
{
|
||||
auto new_version_info = get_github_version_info_async();
|
||||
#if USE_STD_EXPECTED
|
||||
std::expected<github_version_info, std::wstring> new_version_info;
|
||||
#else
|
||||
nonstd::expected<github_version_info, std::wstring> new_version_info;
|
||||
#endif
|
||||
get_github_version_info_async(false, new_version_info).get();
|
||||
if (!new_version_info)
|
||||
{
|
||||
// We couldn't get a new version from github for some reason, log error
|
||||
|
||||
Reference in New Issue
Block a user