From 90e93492a7fbfe0fcd7bf464c12afb7158219292 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 2 Mar 2024 17:42:02 +0100 Subject: [PATCH] fix: Updater not working correctly on Windows --- main/updater/source/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main/updater/source/main.cpp b/main/updater/source/main.cpp index 2e3350e47..d9593bfee 100644 --- a/main/updater/source/main.cpp +++ b/main/updater/source/main.cpp @@ -61,6 +61,8 @@ std::optional downloadUpdate(const std::string &url) { return std::nullopt; } + hex::log::info("Writing update to file: {}", file.getPath().string()); + // Write the downloaded update data to the file file.writeVector(data); @@ -97,7 +99,7 @@ int installUpdate(const std::string &type, std::fs::path updatePath) { }; constexpr static auto UpdateHandlers = { - UpdateHandler { "win-msi", ".msi", "msiexec /fa {} /passive" }, + UpdateHandler { "win-msi", ".msi", "msiexec /passive /package {}" }, UpdateHandler { "macos-dmg", ".dmg", "hdiutil attach {}" }, UpdateHandler { "linux-deb-22.04", ".deb", "sudo apt update && sudo apt install -y --fix-broken {}" }, UpdateHandler { "linux-deb-23.04", ".deb", "sudo apt update && sudo apt install -y --fix-broken {}" }, @@ -108,10 +110,14 @@ int installUpdate(const std::string &type, std::fs::path updatePath) { // Rename the update file to the correct extension const auto originalPath = updatePath; updatePath.replace_extension(handler.extension); + + hex::log::info("Moving update package from {} to {}", originalPath.string(), updatePath.string()); std::fs::rename(originalPath, updatePath); // Install the update using the correct command - hex::startProgram(hex::format(handler.command, updatePath.string())); + const auto command = hex::format(handler.command, updatePath.string()); + hex::log::info("Starting update process with command: '{}'", command); + hex::startProgram(command); return EXIT_SUCCESS; } @@ -163,6 +169,8 @@ int main(int argc, char **argv) { if (!updatePath.has_value()) return EXIT_FAILURE; + hex::log::info("Downloaded update successfully"); + // Install the update return installUpdate(updateType, *updatePath); } \ No newline at end of file