mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
updating: add support for prereleases (#8296)
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="..\..\deps\expected.props" />
|
||||
<ImportGroup Label="Shared" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
|
||||
@@ -81,13 +81,14 @@ std::optional<std::wstring> dispatch_json_action_to_module(const json::JsonObjec
|
||||
}
|
||||
else if (action == L"check_for_updates")
|
||||
{
|
||||
std::wstring latestVersion = check_for_updates();
|
||||
VersionHelper current_version(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);
|
||||
bool isRunningLatest = latestVersion.compare(current_version.toWstring()) == 0;
|
||||
auto new_version_info = check_for_updates();
|
||||
const VersionHelper latestVersion =
|
||||
new_version_info ? new_version_info->version :
|
||||
VersionHelper{ VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION };
|
||||
|
||||
json::JsonObject json;
|
||||
json.SetNamedValue(L"version", json::JsonValue::CreateStringValue(latestVersion));
|
||||
json.SetNamedValue(L"isVersionLatest", json::JsonValue::CreateBooleanValue(isRunningLatest));
|
||||
json.SetNamedValue(L"version", json::JsonValue::CreateStringValue(latestVersion.toWstring()));
|
||||
json.SetNamedValue(L"isVersionLatest", json::JsonValue::CreateBooleanValue(!new_version_info));
|
||||
|
||||
result.emplace(json.Stringify());
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <common/timeutil.h>
|
||||
#include <common/updating/installer.h>
|
||||
#include <common/updating/updating.h>
|
||||
#include <common/updating/notifications.h>
|
||||
#include <runner/general_settings.h>
|
||||
|
||||
extern "C" IMAGE_DOS_HEADER __ImageBase;
|
||||
@@ -74,17 +75,25 @@ void github_update_worker()
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring check_for_updates()
|
||||
std::optional<updating::new_version_download_info> check_for_updates()
|
||||
{
|
||||
try
|
||||
{
|
||||
return updating::check_new_version_available(Strings).get();
|
||||
const auto new_version = updating::get_new_github_version_info_async(Strings).get();
|
||||
if (!new_version)
|
||||
{
|
||||
updating::notifications::show_unavailable(Strings, std::move(new_version.error()));
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
updating::notifications::show_available(new_version.value(), Strings);
|
||||
return std::move(new_version.value());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Couldn't autoupdate
|
||||
return std::wstring();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool launch_pending_update()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <common/updating/updating.h>
|
||||
|
||||
bool start_msi_uninstallation_sequence();
|
||||
void github_update_worker();
|
||||
std::wstring check_for_updates();
|
||||
std::optional<updating::new_version_download_info> check_for_updates();
|
||||
bool launch_pending_update();
|
||||
Reference in New Issue
Block a user