Fix self-update on windows (#712)

Fixed #702


* Add new dep windows v0.44.0 for windows only
* Add regression test for #702
* Impl `win::replace_file`
* Use `ReplaceFileW` on windows if `fs::rename` in `fs::atomic_install` fails
* Improve logging and err messages
* Add more regression tests
* Make `BinFile::install_link` atomic: Do not remove file if dst exists
* Fallback to `ReplaceFileW` in `fs::atomic_symlink_file`
* Refactor: Extract new fn `fs::persist`
* Use `fs::persist` instead of `TempFile::persist` in `fs::atomic_install`, which fallbacks to `ReplaceFileW` on windows

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: Félix Saparelli <felix@passcod.name>
This commit is contained in:
Jiahao XU 2023-01-17 18:05:07 +11:00 committed by GitHub
parent a60ae7ef6c
commit ab4da7f059
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 153 additions and 38 deletions

View file

@ -39,6 +39,9 @@ tracing = "0.1.37"
url = { version = "2.3.1", features = ["serde"] }
xz2 = "0.1.7"
[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.44.0", features = ["Win32_Storage_FileSystem", "Win32_Foundation"] }
[features]
default = ["static", "rustls"]