From dd8cc86bec5ac18646eede9cf013a31723f500a4 Mon Sep 17 00:00:00 2001 From: Micah Date: Wed, 10 Jul 2024 17:40:19 -0700 Subject: [PATCH] Fix permissions bug with self-update on windows --- CHANGELOG.md | 6 ++++++ lib/storage/tool_storage.rs | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9006e9..70e9f70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- `rokit self-update` will no longer encounter an OS error on Windows systems + ## `0.1.3` - June 18th, 2024 ### Changed diff --git a/lib/storage/tool_storage.rs b/lib/storage/tool_storage.rs index 2f4fe78..c24a615 100644 --- a/lib/storage/tool_storage.rs +++ b/lib/storage/tool_storage.rs @@ -208,7 +208,14 @@ impl ToolStorage { // with the OS killing the current executable when its overwritten. if rokit_link_existed { let temp_file = tempfile::tempfile()?; - let temp_path = temp_file.path()?; + let mut temp_path = temp_file.path()?; + #[cfg(windows)] + { + // Windows raises an OS error if the current binary is + // renamed to a file name without a .exe extension. So to + // avoid that, we add the extension. + temp_path.set_extension("exe"); + } trace!( ?temp_path, "moving existing Rokit binary to temporary location"