From 2a8f0a4d4076662bd5ed7816d103e1b7abd2efbc 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 e7451cdc9ed..16b3a24d084 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3165,7 +3165,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", @@ -3175,7 +3175,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)", ] @@ -3183,7 +3183,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)", ] @@ -3249,7 +3249,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)", @@ -3276,7 +3276,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" @@ -3293,7 +3293,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" @@ -3310,7 +3310,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" @@ -3321,7 +3321,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" @@ -3338,7 +3338,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" @@ -3355,7 +3355,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" @@ -3372,7 +3372,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" @@ -3389,7 +3389,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 d03980df850..5ec1af4e523 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)) {