refactor(updating): update async methods to use std::expected and co_await

This commit is contained in:
Gordon Lam (SH)
2026-02-05 12:04:12 -08:00
parent 6d3bb8cc8d
commit 743feb7ce3
4 changed files with 47 additions and 22 deletions

View File

@@ -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