fix: prevent self-upgrade from overwriting itself

This commit is contained in:
daimond113 2024-10-12 18:07:05 +02:00
parent 85d2300c6a
commit 48c5d159b4
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C
2 changed files with 8 additions and 5 deletions

View file

@ -5,6 +5,10 @@ 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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
- Fix `self-upgrade` overwriting its own binary by @daimond113
## [0.5.0-rc.4] - 2024-10-12 ## [0.5.0-rc.4] - 2024-10-12
### Added ### Added
- Add `yes` argument to skip all prompts in publish command by @daimond113 - Add `yes` argument to skip all prompts in publish command by @daimond113

View file

@ -1,7 +1,4 @@
use crate::cli::{ use crate::cli::{config::read_config, version::get_or_download_version};
config::read_config,
version::{get_or_download_version, update_bin_exe},
};
use clap::Args; use clap::Args;
#[derive(Debug, Args)] #[derive(Debug, Args)]
@ -12,7 +9,9 @@ impl SelfUpgradeCommand {
let config = read_config()?; let config = read_config()?;
get_or_download_version(&reqwest, &config.last_checked_updates.unwrap().1)?; get_or_download_version(&reqwest, &config.last_checked_updates.unwrap().1)?;
update_bin_exe()?; // a call to `update_bin_exe` or other similar function *should* be here, in case new versions
// have fixes to bugs in executing other versions, but that would cause
// the current file to be overwritten by itself, so this needs more thought
Ok(()) Ok(())
} }