fix: Updater not working correctly on Windows
This commit is contained in:
parent
54266bf63b
commit
90e93492a7
@ -61,6 +61,8 @@ std::optional<std::fs::path> downloadUpdate(const std::string &url) {
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hex::log::info("Writing update to file: {}", file.getPath().string());
|
||||||
|
|
||||||
// Write the downloaded update data to the file
|
// Write the downloaded update data to the file
|
||||||
file.writeVector(data);
|
file.writeVector(data);
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ int installUpdate(const std::string &type, std::fs::path updatePath) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constexpr static auto UpdateHandlers = {
|
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 { "macos-dmg", ".dmg", "hdiutil attach {}" },
|
||||||
UpdateHandler { "linux-deb-22.04", ".deb", "sudo apt update && sudo apt install -y --fix-broken {}" },
|
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 {}" },
|
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
|
// Rename the update file to the correct extension
|
||||||
const auto originalPath = updatePath;
|
const auto originalPath = updatePath;
|
||||||
updatePath.replace_extension(handler.extension);
|
updatePath.replace_extension(handler.extension);
|
||||||
|
|
||||||
|
hex::log::info("Moving update package from {} to {}", originalPath.string(), updatePath.string());
|
||||||
std::fs::rename(originalPath, updatePath);
|
std::fs::rename(originalPath, updatePath);
|
||||||
|
|
||||||
// Install the update using the correct command
|
// 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;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -163,6 +169,8 @@ int main(int argc, char **argv) {
|
|||||||
if (!updatePath.has_value())
|
if (!updatePath.has_value())
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
hex::log::info("Downloaded update successfully");
|
||||||
|
|
||||||
// Install the update
|
// Install the update
|
||||||
return installUpdate(updateType, *updatePath);
|
return installUpdate(updateType, *updatePath);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user