From 48178440c0a6a1c4070b2fb29bdb04ffa8be7198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Thu, 25 Jul 2024 16:27:59 +0200 Subject: [PATCH 1/5] refactor: use windows-sys instead of winapi (#2233) --- Cargo.lock | 2 +- Cargo.toml | 15 +++++++-------- src/commands.rs | 28 +++++++++++++--------------- src/compiler/msvc.rs | 16 +++++++++------- src/util.rs | 28 +++++++++++++++++----------- 5 files changed, 47 insertions(+), 42 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc255b955..bf4c3425d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2605,7 +2605,7 @@ dependencies = [ "version-compare", "walkdir", "which", - "winapi", + "windows-sys 0.52.0", "zip", "zstd", ] diff --git a/Cargo.toml b/Cargo.toml index 47f1090ab..b2779cbe8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -140,16 +140,15 @@ daemonize = "0.5" optional = true version = "0.1.15" -[target.'cfg(windows)'.dependencies.winapi] +[target.'cfg(windows)'.dependencies.windows-sys] features = [ - "fileapi", - "handleapi", - "stringapiset", - "winnls", - "processenv", - "std", + "Win32_Foundation", + "Win32_Globalization", + "Win32_Storage_FileSystem", + "Win32_System_Threading", + "Win32_System_Console", ] -version = "0.3" +version = "0.52" [features] all = [ diff --git a/src/commands.rs b/src/commands.rs index ab740582e..2b68df1e0 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -133,11 +133,10 @@ fn redirect_stderr(f: File) { #[cfg(windows)] fn redirect_stderr(f: File) { use std::os::windows::io::IntoRawHandle; - use winapi::um::processenv::SetStdHandle; - use winapi::um::winbase::STD_ERROR_HANDLE; + use windows_sys::Win32::System::Console::{SetStdHandle, STD_ERROR_HANDLE}; // Ignore errors here. unsafe { - SetStdHandle(STD_ERROR_HANDLE, f.into_raw_handle()); + SetStdHandle(STD_ERROR_HANDLE, f.into_raw_handle() as _); } } @@ -176,11 +175,10 @@ fn run_server_process(startup_timeout: Option) -> Result) -> Result() as DWORD; + si.cb = mem::size_of::() as _; if unsafe { CreateProcessW( exe.as_mut_ptr(), ptr::null_mut(), ptr::null_mut(), ptr::null_mut(), - FALSE, + 0, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW, - envp.as_mut_ptr() as LPVOID, + envp.as_mut_ptr().cast(), workdir.as_ptr(), - &mut si, + &si, &mut pi, - ) == TRUE + ) != 0 } { unsafe { CloseHandle(pi.hProcess); diff --git a/src/compiler/msvc.rs b/src/compiler/msvc.rs index 4ec7bf155..ccf77ce75 100644 --- a/src/compiler/msvc.rs +++ b/src/compiler/msvc.rs @@ -112,8 +112,10 @@ fn from_local_codepage(multi_byte_str: &[u8]) -> io::Result { #[cfg(windows)] pub fn from_local_codepage(multi_byte_str: &[u8]) -> io::Result { - let codepage = winapi::um::winnls::CP_OEMCP; - let flags = winapi::um::winnls::MB_ERR_INVALID_CHARS; + use windows_sys::Win32::Globalization::{MultiByteToWideChar, CP_OEMCP, MB_ERR_INVALID_CHARS}; + + let codepage = CP_OEMCP; + let flags = MB_ERR_INVALID_CHARS; // Empty string if multi_byte_str.is_empty() { @@ -121,7 +123,7 @@ pub fn from_local_codepage(multi_byte_str: &[u8]) -> io::Result { } unsafe { // Get length of UTF-16 string - let len = winapi::um::stringapiset::MultiByteToWideChar( + let len = MultiByteToWideChar( codepage, flags, multi_byte_str.as_ptr() as _, @@ -132,7 +134,7 @@ pub fn from_local_codepage(multi_byte_str: &[u8]) -> io::Result { if len > 0 { // Convert to UTF-16 let mut wstr: Vec = Vec::with_capacity(len as usize); - let len = winapi::um::stringapiset::MultiByteToWideChar( + let len = MultiByteToWideChar( codepage, flags, multi_byte_str.as_ptr() as _, @@ -832,10 +834,10 @@ fn normpath(path: &str) -> String { use std::os::windows::ffi::OsStringExt; use std::os::windows::io::AsRawHandle; use std::ptr; - use winapi::um::fileapi::GetFinalPathNameByHandleW; + use windows_sys::Win32::Storage::FileSystem::GetFinalPathNameByHandleW; File::open(path) .and_then(|f| { - let handle = f.as_raw_handle(); + let handle = f.as_raw_handle() as _; let size = unsafe { GetFinalPathNameByHandleW(handle, ptr::null_mut(), 0, 0) }; if size == 0 { return Err(io::Error::last_os_error()); @@ -2582,7 +2584,7 @@ mod test { #[cfg(windows)] fn local_oem_codepage_conversions() { use crate::util::wide_char_to_multi_byte; - use winapi::um::winnls::GetOEMCP; + use windows_sys::Win32::Globalization::GetOEMCP; let current_oemcp = unsafe { GetOEMCP() }; // We don't control the local OEM codepage so test only if it is one of: diff --git a/src/util.rs b/src/util.rs index 4fc45af2e..2000ae832 100644 --- a/src/util.rs +++ b/src/util.rs @@ -636,15 +636,19 @@ pub fn decode_path(bytes: &[u8]) -> std::io::Result { #[cfg(windows)] pub fn decode_path(bytes: &[u8]) -> std::io::Result { - let codepage = winapi::um::winnls::CP_OEMCP; - let flags = winapi::um::winnls::MB_ERR_INVALID_CHARS; + use windows_sys::Win32::Globalization::{CP_OEMCP, MB_ERR_INVALID_CHARS}; + + let codepage = CP_OEMCP; + let flags = MB_ERR_INVALID_CHARS; Ok(OsString::from_wide(&multi_byte_to_wide_char(codepage, flags, bytes)?).into()) } #[cfg(windows)] pub fn wide_char_to_multi_byte(wide_char_str: &[u16]) -> std::io::Result> { - let codepage = winapi::um::winnls::CP_OEMCP; + use windows_sys::Win32::Globalization::{WideCharToMultiByte, CP_OEMCP}; + + let codepage = CP_OEMCP; let flags = 0; // Empty string if wide_char_str.is_empty() { @@ -652,7 +656,7 @@ pub fn wide_char_to_multi_byte(wide_char_str: &[u16]) -> std::io::Result } unsafe { // Get length of multibyte string - let len = winapi::um::stringapiset::WideCharToMultiByte( + let len = WideCharToMultiByte( codepage, flags, wide_char_str.as_ptr(), @@ -666,7 +670,7 @@ pub fn wide_char_to_multi_byte(wide_char_str: &[u16]) -> std::io::Result if len > 0 { // Convert from UTF-16 to multibyte let mut astr: Vec = Vec::with_capacity(len as usize); - let len = winapi::um::stringapiset::WideCharToMultiByte( + let len = WideCharToMultiByte( codepage, flags, wide_char_str.as_ptr(), @@ -695,19 +699,21 @@ pub fn wide_char_to_multi_byte(wide_char_str: &[u16]) -> std::io::Result /// See https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx /// for more details. pub fn multi_byte_to_wide_char( - codepage: winapi::shared::minwindef::DWORD, - flags: winapi::shared::minwindef::DWORD, + codepage: u32, + flags: u32, multi_byte_str: &[u8], ) -> std::io::Result> { + use windows_sys::Win32::Globalization::MultiByteToWideChar; + if multi_byte_str.is_empty() { return Ok(vec![]); } unsafe { // Get length of UTF-16 string - let len = winapi::um::stringapiset::MultiByteToWideChar( + let len = MultiByteToWideChar( codepage, flags, - multi_byte_str.as_ptr() as winapi::um::winnt::LPSTR, + multi_byte_str.as_ptr(), multi_byte_str.len() as i32, std::ptr::null_mut(), 0, @@ -715,10 +721,10 @@ pub fn multi_byte_to_wide_char( if len > 0 { // Convert to UTF-16 let mut wstr: Vec = Vec::with_capacity(len as usize); - let len = winapi::um::stringapiset::MultiByteToWideChar( + let len = MultiByteToWideChar( codepage, flags, - multi_byte_str.as_ptr() as winapi::um::winnt::LPSTR, + multi_byte_str.as_ptr(), multi_byte_str.len() as i32, wstr.as_mut_ptr(), len, From 29d17c7c5c50b4575afe61b516fb27c1728d5176 Mon Sep 17 00:00:00 2001 From: Maksim Bondarenkov <119937608+ognevny@users.noreply.github.com> Date: Thu, 25 Jul 2024 20:18:52 +0300 Subject: [PATCH 2/5] deps: update winapi-util (#2236) --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf4c3425d..d03335c53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3719,11 +3719,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] From 9cc22d9582c1f8bd3fc41d7698f5522569335d1b Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Fri, 2 Aug 2024 15:05:47 +0800 Subject: [PATCH 3/5] feat: Bump opendal to 0.48.0 (#2240) Signed-off-by: Xuanwo --- Cargo.lock | 126 +++++++++++++++-------------------------- Cargo.toml | 4 +- src/cache/azure.rs | 6 +- src/cache/gcs.rs | 14 ++--- src/cache/gha.rs | 22 +++---- src/cache/memcached.rs | 12 ++-- src/cache/oss.rs | 8 +-- src/cache/redis.rs | 31 +++++----- src/cache/s3.rs | 33 +++++------ src/cache/webdav.rs | 18 ++---- 10 files changed, 115 insertions(+), 159 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d03335c53..502b82dee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1146,7 +1146,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.5", + "socket2", "tokio", "tower-service", "tracing", @@ -1184,7 +1184,7 @@ dependencies = [ "hyper 1.1.0", "hyper-util", "rustls 0.23.10", - "rustls-native-certs 0.7.0", + "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -1234,7 +1234,7 @@ dependencies = [ "http-body 1.0.0", "hyper 1.1.0", "pin-project-lite", - "socket2 0.5.5", + "socket2", "tokio", "tower", "tower-service", @@ -1682,9 +1682,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opendal" -version = "0.47.3" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cac4826fe3d5482a49b92955b0f6b06ce45b46ec84484176588209bfbf996870" +checksum = "615d41187deea0ea7fab5b48e9afef6ae8fc742fdcfa248846ee3d92ff71e986" dependencies = [ "anyhow", "async-trait", @@ -1702,7 +1702,7 @@ dependencies = [ "md-5", "once_cell", "percent-encoding", - "quick-xml", + "quick-xml 0.36.1", "redis", "reqsign", "reqwest 0.12.5", @@ -1976,9 +1976,19 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quick-xml" -version = "0.31.0" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86e446ed58cef1bbfe847bc2fda0e2e4ea9f0e57b90c507d4781292590d72a4e" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "quick-xml" +version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" dependencies = [ "memchr", "serde", @@ -2026,7 +2036,7 @@ checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" dependencies = [ "libc", "once_cell", - "socket2 0.5.5", + "socket2", "tracing", "windows-sys 0.52.0", ] @@ -2072,9 +2082,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.23.3" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f49cdc0bb3f412bf8e7d1bd90fe1d9eb10bc5c399ba90973c14662a27b3f8ba" +checksum = "e0d7a6955c7511f60f3ba9e86c6d02b3c3f144f8c24b288d1f4e18074ab8bbec" dependencies = [ "arc-swap", "async-trait", @@ -2088,14 +2098,16 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rand", - "rustls 0.21.11", - "rustls-native-certs 0.6.3", + "rustls 0.22.4", + "rustls-native-certs", + "rustls-pemfile", + "rustls-pki-types", "ryu", "sha1_smol", - "socket2 0.4.10", + "socket2", "tokio", "tokio-retry", - "tokio-rustls 0.24.1", + "tokio-rustls 0.25.0", "tokio-util", "url", ] @@ -2151,9 +2163,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqsign" -version = "0.15.2" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70fe66d4cd0b5ed9b1abbfe639bf6baeaaf509f7da2d51b31111ba945be59286" +checksum = "03dd4ba7c3901dd43e6b8c7446a760d45bc1ea4301002e1a6fa48f97c3a796fa" dependencies = [ "anyhow", "async-trait", @@ -2169,7 +2181,7 @@ dependencies = [ "log", "once_cell", "percent-encoding", - "quick-xml", + "quick-xml 0.35.0", "rand", "reqwest 0.12.5", "rsa", @@ -2249,8 +2261,8 @@ dependencies = [ "pin-project-lite", "quinn", "rustls 0.23.10", - "rustls-native-certs 0.7.0", - "rustls-pemfile 2.1.2", + "rustls-native-certs", + "rustls-pemfile", "rustls-pki-types", "serde", "serde_json", @@ -2384,14 +2396,16 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.11" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", "ring", - "rustls-webpki 0.101.7", - "sct", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", ] [[package]] @@ -2403,23 +2417,11 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.102.4", + "rustls-webpki", "subtle", "zeroize", ] -[[package]] -name = "rustls-native-certs" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" -dependencies = [ - "openssl-probe", - "rustls-pemfile 1.0.4", - "schannel", - "security-framework", -] - [[package]] name = "rustls-native-certs" version = "0.7.0" @@ -2427,21 +2429,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.2", + "rustls-pemfile", "rustls-pki-types", "schannel", "security-framework", ] -[[package]] -name = "rustls-pemfile" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" -dependencies = [ - "base64 0.21.7", -] - [[package]] name = "rustls-pemfile" version = "2.1.2" @@ -2458,16 +2451,6 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" -[[package]] -name = "rustls-webpki" -version = "0.101.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "rustls-webpki" version = "0.102.4" @@ -2636,16 +2619,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "sdd" version = "0.2.0" @@ -2844,16 +2817,6 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" -[[package]] -name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "socket2" version = "0.5.5" @@ -3228,7 +3191,7 @@ dependencies = [ "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.5", + "socket2", "tokio-macros", "windows-sys 0.48.0", ] @@ -3267,11 +3230,12 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" dependencies = [ - "rustls 0.21.11", + "rustls 0.22.4", + "rustls-pki-types", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index b2779cbe8..9437e7369 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,11 +64,11 @@ mime = "0.3" num_cpus = "1.16" number_prefix = "0.4" once_cell = "1.19" -opendal = { version = "0.47.3", optional = true, default-features = false } +opendal = { version = "0.48.0", optional = true, default-features = false } openssl = { version = "0.10.64", optional = true } rand = "0.8.4" regex = "1.10.3" -reqsign = { version = "0.15.2", optional = true } +reqsign = { version = "0.16.0", optional = true } reqwest = { version = "0.12", features = [ "json", "blocking", diff --git a/src/cache/azure.rs b/src/cache/azure.rs index 6faca3db1..59160b309 100644 --- a/src/cache/azure.rs +++ b/src/cache/azure.rs @@ -24,9 +24,9 @@ pub struct AzureBlobCache; impl AzureBlobCache { pub fn build(connection_string: &str, container: &str, key_prefix: &str) -> Result { - let mut builder = Azblob::from_connection_string(connection_string)?; - builder.container(container); - builder.root(key_prefix); + let builder = Azblob::from_connection_string(connection_string)? + .container(container) + .root(key_prefix); let op = Operator::new(builder)? .layer(LoggingLayer::default()) diff --git a/src/cache/gcs.rs b/src/cache/gcs.rs index 79fbbd4ce..cc5216d73 100644 --- a/src/cache/gcs.rs +++ b/src/cache/gcs.rs @@ -42,24 +42,24 @@ impl GCSCache { rw_mode: CacheMode, credential_url: Option<&str>, ) -> Result { - let mut builder = Gcs::default(); - builder.bucket(bucket); - builder.root(key_prefix); - builder.scope(rw_to_scope(rw_mode)); + let mut builder = Gcs::default() + .bucket(bucket) + .root(key_prefix) + .scope(rw_to_scope(rw_mode)); if let Some(service_account) = service_account { - builder.service_account(service_account); + builder = builder.service_account(service_account); } if let Some(path) = cred_path { - builder.credential_path(path); + builder = builder.credential_path(path); } if let Some(cred_url) = credential_url { let _ = Url::parse(cred_url) .map_err(|err| anyhow!("gcs credential url is invalid: {err:?}"))?; - builder.customed_token_loader(Box::new(TaskClusterTokenLoader { + builder = builder.customized_token_loader(Box::new(TaskClusterTokenLoader { scope: rw_to_scope(rw_mode).to_string(), url: cred_url.to_string(), })); diff --git a/src/cache/gha.rs b/src/cache/gha.rs index 8d8373430..28f6b3752 100644 --- a/src/cache/gha.rs +++ b/src/cache/gha.rs @@ -24,19 +24,19 @@ pub struct GHACache; impl GHACache { pub fn build(version: &str) -> Result { - let mut builder = Ghac::default(); - // This is the prefix of gha cache. - // From user side, cache key will be like `sccache/f/c/b/fcbxxx` - // - // User customization is theoretically supported, but I decided - // to see the community feedback first. - builder.root("/sccache"); + let mut builder = Ghac::default() + // This is the prefix of gha cache. + // From user side, cache key will be like `sccache/f/c/b/fcbxxx` + // + // User customization is theoretically supported, but I decided + // to see the community feedback first. + .root("/sccache"); - if version.is_empty() { - builder.version(&format!("sccache-v{VERSION}")); + builder = if version.is_empty() { + builder.version(&format!("sccache-v{VERSION}")) } else { - builder.version(&format!("sccache-v{VERSION}-{version}")); - } + builder.version(&format!("sccache-v{VERSION}-{version}")) + }; let op = Operator::new(builder)? .layer(LoggingLayer::default()) diff --git a/src/cache/memcached.rs b/src/cache/memcached.rs index b5735fc90..f01ca48bc 100644 --- a/src/cache/memcached.rs +++ b/src/cache/memcached.rs @@ -32,18 +32,18 @@ impl MemcachedCache { key_prefix: &str, expiration: u32, ) -> Result { - let mut builder = Memcached::default(); - builder.endpoint(url); + let mut builder = Memcached::default().endpoint(url); if let Some(username) = username { - builder.username(username); + builder = builder.username(username); } if let Some(password) = password { - builder.password(password); + builder = builder.password(password); } - builder.root(key_prefix); - builder.default_ttl(Duration::from_secs(expiration.into())); + builder = builder + .root(key_prefix) + .default_ttl(Duration::from_secs(expiration.into())); let op = Operator::new(builder)? .layer(LoggingLayer::default()) diff --git a/src/cache/oss.rs b/src/cache/oss.rs index e98e8ccc2..208179d17 100644 --- a/src/cache/oss.rs +++ b/src/cache/oss.rs @@ -26,18 +26,16 @@ impl OSSCache { endpoint: Option<&str>, no_credentials: bool, ) -> Result { - let mut builder = Oss::default(); - builder.bucket(bucket); - builder.root(key_prefix); + let mut builder = Oss::default().bucket(bucket).root(key_prefix); if let Some(endpoint) = endpoint { - builder.endpoint(endpoint); + builder = builder.endpoint(endpoint); } if no_credentials { // Allow anonymous access to OSS so that OpenDAL will not // throw error when no credentials are provided. - builder.allow_anonymous(); + builder = builder.allow_anonymous(); } let op = Operator::new(builder)? diff --git a/src/cache/redis.rs b/src/cache/redis.rs index 23c60b638..215bdc7ab 100644 --- a/src/cache/redis.rs +++ b/src/cache/redis.rs @@ -29,20 +29,20 @@ impl RedisCache { pub fn build_from_url(url: &str, key_prefix: &str, ttl: u64) -> Result { let parsed = Url::parse(url)?; - let mut builder = Redis::default(); - builder.endpoint(parsed.as_str()); - builder.username(parsed.username()); - builder.password(parsed.password().unwrap_or_default()); - builder.root(key_prefix); + let mut builder = Redis::default() + .endpoint(parsed.as_str()) + .username(parsed.username()) + .password(parsed.password().unwrap_or_default()) + .root(key_prefix); if ttl != 0 { - builder.default_ttl(Duration::from_secs(ttl)); + builder = builder.default_ttl(Duration::from_secs(ttl)); } let options: HashMap<_, _> = parsed .query_pairs() .map(|(k, v)| (k.to_string(), v.to_string())) .collect(); - builder.db(options + builder = builder.db(options .get("db") .map(|v| v.parse().unwrap_or_default()) .unwrap_or_default()); @@ -62,8 +62,7 @@ impl RedisCache { key_prefix: &str, ttl: u64, ) -> Result { - let mut builder = Redis::default(); - builder.endpoint(endpoint); + let builder = Redis::default().endpoint(endpoint); Self::build_common(builder, username, password, db, key_prefix, ttl) } @@ -77,8 +76,7 @@ impl RedisCache { key_prefix: &str, ttl: u64, ) -> Result { - let mut builder = Redis::default(); - builder.cluster_endpoints(endpoints); + let builder = Redis::default().cluster_endpoints(endpoints); Self::build_common(builder, username, password, db, key_prefix, ttl) } @@ -91,13 +89,14 @@ impl RedisCache { key_prefix: &str, ttl: u64, ) -> Result { - builder.username(username.unwrap_or_default()); - builder.password(password.unwrap_or_default()); - builder.root(key_prefix); + builder = builder + .username(username.unwrap_or_default()) + .password(password.unwrap_or_default()) + .db(db.into()) + .root(key_prefix); if ttl != 0 { - builder.default_ttl(Duration::from_secs(ttl)); + builder = builder.default_ttl(Duration::from_secs(ttl)); } - builder.db(db.into()); let op = Operator::new(builder)? .layer(LoggingLayer::default()) diff --git a/src/cache/s3.rs b/src/cache/s3.rs index 000c3213c..cd33b7846 100644 --- a/src/cache/s3.rs +++ b/src/cache/s3.rs @@ -30,33 +30,34 @@ impl S3Cache { use_ssl: Option, server_side_encryption: Option, ) -> Result { - let mut builder = S3::default(); - builder.http_client(set_user_agent()); - builder.bucket(bucket); - builder.root(key_prefix); + let mut builder = S3::default() + .http_client(set_user_agent()) + .bucket(bucket) + .root(key_prefix); if let Some(region) = region { - builder.region(region); + builder = builder.region(region); } if no_credentials { - builder.disable_config_load(); - // Disable EC2 metadata to avoid OpenDAL trying to load - // credentials from EC2 metadata. - // - // A.k.a, don't try to visit `http://169.254.169.254` - builder.disable_ec2_metadata(); - // Allow anonymous access to S3 so that OpenDAL will not - // throw error when no credentials are provided. - builder.allow_anonymous(); + builder = builder + .disable_config_load() + // Disable EC2 metadata to avoid OpenDAL trying to load + // credentials from EC2 metadata. + // + // A.k.a, don't try to visit `http://169.254.169.254` + .disable_ec2_metadata() + // Allow anonymous access to S3 so that OpenDAL will not + // throw error when no credentials are provided. + .allow_anonymous(); } if let Some(endpoint) = endpoint { - builder.endpoint(&endpoint_resolver(endpoint, use_ssl)?); + builder = builder.endpoint(&endpoint_resolver(endpoint, use_ssl)?); } if server_side_encryption.unwrap_or_default() { - builder.server_side_encryption_with_s3_key(); + builder = builder.server_side_encryption_with_s3_key(); } let op = Operator::new(builder)? diff --git a/src/cache/webdav.rs b/src/cache/webdav.rs index f9c0ea56f..a88cd17ce 100644 --- a/src/cache/webdav.rs +++ b/src/cache/webdav.rs @@ -27,18 +27,12 @@ impl WebdavCache { password: Option<&str>, token: Option<&str>, ) -> Result { - let mut builder = Webdav::default(); - builder.endpoint(endpoint); - builder.root(key_prefix); - if let Some(username) = username { - builder.username(username); - } - if let Some(password) = password { - builder.password(password); - } - if let Some(token) = token { - builder.token(token); - } + let builder = Webdav::default() + .endpoint(endpoint) + .root(key_prefix) + .username(username.unwrap_or_default()) + .password(password.unwrap_or_default()) + .token(token.unwrap_or_default()); let op = Operator::new(builder)? .layer(LoggingLayer::default()) From 0e6656243102299844cf344136b5e76f42a5a8ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 17:02:46 +0800 Subject: [PATCH 4/5] build(deps): bump log from 0.4.20 to 0.4.22 (#2218) Bumps [log](https://github.com/rust-lang/log) from 0.4.20 to 0.4.22. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.20...0.4.22) --- updated-dependencies: - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 502b82dee..49f38ab50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1426,9 +1426,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "match_cfg" From 95455ad45cf4266ebbd56f35c1a46a1877327d10 Mon Sep 17 00:00:00 2001 From: Hiroshi Yamauchi <56735936+hjyamauchi@users.noreply.github.com> Date: Wed, 7 Aug 2024 12:23:02 -0700 Subject: [PATCH 5/5] Add windows arm64 to the CI (#2243) --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68e13848d..1eb95f7f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -160,6 +160,9 @@ jobs: - os: windows-2019 target: x86_64-pc-windows-msvc rustflags: -Ctarget-feature=+crt-static + - os: windows-2019 + target: aarch64-pc-windows-msvc + rustflags: -Ctarget-feature=+crt-static steps: - name: Clone repository uses: actions/checkout@v4