diff options
| author | JMC47 <JMC4789@gmail.com> | 2022-10-21 13:55:51 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-21 13:55:51 -0400 |
| commit | 00e23da6074b5b25a2ff4e4ff040986c07753e94 (patch) | |
| tree | 2831c77c6a2aabb04c1d53c408df0b20dd6d0efe /Source/Core/UpdaterCommon/UpdaterCommon.cpp | |
| parent | 9222956acdfb6a0526b6fdada4aeaa936de9fcd1 (diff) | |
| parent | 717c36bc43c2a568b3fff04bd6d3ea2a81c0582d (diff) | |
Merge pull request #11051 from shuffle2/update-vcredist
WinUpdater: Check OS and VC++ Redist versions
Diffstat (limited to 'Source/Core/UpdaterCommon/UpdaterCommon.cpp')
| -rw-r--r-- | Source/Core/UpdaterCommon/UpdaterCommon.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/Core/UpdaterCommon/UpdaterCommon.cpp b/Source/Core/UpdaterCommon/UpdaterCommon.cpp index fb9606ca49..dee55965bf 100644 --- a/Source/Core/UpdaterCommon/UpdaterCommon.cpp +++ b/Source/Core/UpdaterCommon/UpdaterCommon.cpp @@ -18,6 +18,7 @@ #include "Common/HttpRequest.h" #include "Common/ScopeGuard.h" #include "Common/StringUtil.h" +#include "UpdaterCommon/Platform.h" #include "UpdaterCommon/UI.h" #ifndef _WIN32 @@ -278,6 +279,41 @@ bool DownloadContent(const std::vector<TodoList::DownloadOp>& to_download, return true; } +bool PlatformVersionCheck(const std::vector<TodoList::UpdateOp>& to_update, + const std::string& install_base_path, const std::string& temp_dir) +{ + UI::SetDescription("Checking platform..."); + + const auto op_it = std::find_if(to_update.cbegin(), to_update.cend(), + [&](const auto& op) { return op.filename == "build_info.txt"; }); + if (op_it == to_update.cend()) + return true; + + const auto op = *op_it; + std::string build_info_path = + temp_dir + DIR_SEP + HexEncode(op.new_hash.data(), op.new_hash.size()); + std::string build_info_content; + if (!File::ReadFileToString(build_info_path, build_info_content) || + op.new_hash != ComputeHash(build_info_content)) + { + fprintf(log_fp, "Failed to read %s\n.", build_info_path.c_str()); + return false; + } + auto next_build_info = Platform::BuildInfo(build_info_content); + + build_info_path = install_base_path + DIR_SEP + "build_info.txt"; + auto this_build_info = Platform::BuildInfo(); + if (File::ReadFileToString(build_info_path, build_info_content)) + { + if (op.old_hash != ComputeHash(build_info_content)) + fprintf(log_fp, "Using modified existing BuildInfo %s.\n", build_info_path.c_str()); + this_build_info = Platform::BuildInfo(build_info_content); + } + + // The existing BuildInfo may have been modified. Be careful not to overly trust its contents! + return Platform::VersionCheck(this_build_info, next_build_info); +} + TodoList ComputeActionsToDo(Manifest this_manifest, Manifest next_manifest) { TodoList todo; @@ -474,6 +510,11 @@ bool PerformUpdate(const TodoList& todo, const std::string& install_base_path, return false; fprintf(log_fp, "Download step completed.\n"); + fprintf(log_fp, "Starting platform version check step...\n"); + if (!PlatformVersionCheck(todo.to_update, install_base_path, temp_path)) + return false; + fprintf(log_fp, "Platform version check step completed.\n"); + fprintf(log_fp, "Starting update step...\n"); if (!UpdateFiles(todo.to_update, install_base_path, temp_path)) return false; |
