Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
t-mw authored Feb 24, 2021
2 parents 97787bf + 96d7171 commit c7c7ee3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
### Added
### Changed
- Fix io error triggered when updating binary contained in a zipped folder.
- Fix issues updating Windows binaries on non-`C:` drives.
### Removed

## [0.24.0]
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,10 @@ impl<'a> Move<'a> {
}
Some(temp) => {
if dest.exists() {
fs::rename(dest, temp)?;
// Copy the destination file rather than renaming it, so that
// if it is a running executable the temp file can be removed
// on Windows while the executable is running.
fs::copy(dest, temp)?;
if let Err(e) = fs::rename(self.source, dest) {
fs::rename(temp, dest)?;
return Err(Error::from(e));
Expand Down
10 changes: 4 additions & 6 deletions src/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,10 @@ pub trait ReleaseUpdate {
confirm("Do you want to continue? [Y/n] ")?;
}

let tmp_dir_parent = if cfg!(windows) {
env::var_os("TEMP").map(PathBuf::from)
} else {
bin_install_path.parent().map(PathBuf::from)
}
.ok_or_else(|| Error::Update("Failed to determine parent dir".into()))?;
let tmp_dir_parent = bin_install_path
.parent()
.map(PathBuf::from)
.ok_or_else(|| Error::Update("Failed to determine parent dir".into()))?;
let tmp_dir = tempfile::Builder::new()
.prefix(&format!("{}_download", bin_name))
.tempdir_in(tmp_dir_parent)?;
Expand Down

0 comments on commit c7c7ee3

Please sign in to comment.