From 00db1260758fb8be5485c880ad6b8a4cf4ef699c Mon Sep 17 00:00:00 2001 From: Yue Fei Date: Tue, 24 Sep 2024 16:39:59 +0800 Subject: [PATCH] Update --- Cargo.lock | 24 ++++++++++++------------ src/cli/self_update/windows.rs | 13 ++++++------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c58a949921..4c3db44633 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3179,7 +3179,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-registry" version = "0.2.0" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" dependencies = [ "windows-result", "windows-strings", @@ -3189,7 +3189,7 @@ dependencies = [ [[package]] name = "windows-result" version = "0.2.0" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" dependencies = [ "windows-targets 0.52.6 (git+https://github.com/microsoft/windows-rs.git)", ] @@ -3197,7 +3197,7 @@ dependencies = [ [[package]] name = "windows-strings" version = "0.1.0" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" dependencies = [ "windows-targets 0.52.6 (git+https://github.com/microsoft/windows-rs.git)", ] @@ -3263,7 +3263,7 @@ dependencies = [ [[package]] name = "windows-targets" version = "0.52.6" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" dependencies = [ "windows_aarch64_gnullvm 0.52.6 (git+https://github.com/microsoft/windows-rs.git)", "windows_aarch64_msvc 0.52.6 (git+https://github.com/microsoft/windows-rs.git)", @@ -3290,7 +3290,7 @@ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" [[package]] name = "windows_aarch64_msvc" @@ -3307,7 +3307,7 @@ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" [[package]] name = "windows_i686_gnu" @@ -3324,7 +3324,7 @@ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" version = "0.52.6" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" [[package]] name = "windows_i686_gnullvm" @@ -3335,7 +3335,7 @@ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" [[package]] name = "windows_i686_msvc" @@ -3352,7 +3352,7 @@ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" version = "0.52.6" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" [[package]] name = "windows_x86_64_gnu" @@ -3369,7 +3369,7 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" [[package]] name = "windows_x86_64_gnullvm" @@ -3386,7 +3386,7 @@ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" [[package]] name = "windows_x86_64_msvc" @@ -3403,7 +3403,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" -source = "git+https://github.com/microsoft/windows-rs.git#26635b2c00ead392b24e4fddd174027a503a1234" +source = "git+https://github.com/microsoft/windows-rs.git#0f7466c34e774e547d21c579b58b60168c4ee6bc" [[package]] name = "winnow" diff --git a/src/cli/self_update/windows.rs b/src/cli/self_update/windows.rs index d03980df85..5ec1af4e52 100644 --- a/src/cli/self_update/windows.rs +++ b/src/cli/self_update/windows.rs @@ -2,6 +2,7 @@ use std::env::{consts::EXE_SUFFIX, split_paths}; use std::ffi::{OsStr, OsString}; use std::fmt; use std::io::Write; +use std::ops::Deref; use std::os::windows::ffi::OsStrExt; use std::path::Path; use std::process::Command; @@ -530,9 +531,8 @@ fn _add_to_path(old_path: HSTRING, path_str: HSTRING) -> Option { if old_path.is_empty() { Some(path_str) } else if old_path - .as_wide() .windows(path_str.len()) - .any(|path| path == path_str.as_wide()) + .any(|path| path == path_str.deref()) { None } else { @@ -546,20 +546,19 @@ fn _add_to_path(old_path: HSTRING, path_str: HSTRING) -> Option { // Returns None if the existing old_path does not need changing fn _remove_from_path(old_path: HSTRING, path_str: HSTRING) -> Option { let idx = old_path - .as_wide() .windows(path_str.len()) - .position(|path| path == path_str.as_wide())?; + .position(|path| path == path_str.deref())?; // If there's a trailing semicolon (likely, since we probably added one // during install), include that in the substring to remove. We don't search // for that to find the string, because if it's the last string in the path, // there may not be. let mut len = path_str.len(); - if old_path.as_wide().get(idx + path_str.len()) == Some(&(b';' as u16)) { + if old_path.get(idx + path_str.len()) == Some(&(b';' as u16)) { len += 1; } - let mut new_path = old_path.as_wide()[..idx].to_owned(); - new_path.extend_from_slice(&old_path.as_wide()[idx + len..]); + let mut new_path = old_path[..idx].to_owned(); + new_path.extend_from_slice(&old_path[idx + len..]); // Don't leave a trailing ; though, we don't want an empty string in the // path. if new_path.last() == Some(&(b';' as u16)) {