From 9de171fb8333bd0bcf18217710d696fa7a5d80d1 Mon Sep 17 00:00:00 2001 From: Christian Visintin Date: Sun, 20 Aug 2023 10:24:34 +0200 Subject: [PATCH] added cfg smb-windows to be able to disable SMB on windows (#210) * added cfg smb-windows to be able to disable SMB on windows * lint --- build.rs | 3 ++- src/filetransfer/builder.rs | 2 +- src/ui/activities/setup/actions.rs | 2 +- src/utils/parser.rs | 10 +++++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/build.rs b/build.rs index 2b7d1a8..543d2da 100644 --- a/build.rs +++ b/build.rs @@ -10,6 +10,7 @@ fn main() { windows: { target_family = "windows" }, // exclusive features smb: { all(feature = "smb", not( macos )) }, - smb_unix: { all(unix, feature = "smb", not(macos)) } + smb_unix: { all(unix, feature = "smb", not(macos)) }, + smb_windows: { all(windows, feature = "smb") } } } diff --git a/src/filetransfer/builder.rs b/src/filetransfer/builder.rs index aef366d..c60ab28 100644 --- a/src/filetransfer/builder.rs +++ b/src/filetransfer/builder.rs @@ -140,7 +140,7 @@ impl Builder { } } - #[cfg(windows)] + #[cfg(smb_windows)] fn smb_client(params: SmbParams) -> SmbFs { let mut credentials = SmbCredentials::new(params.address, params.share); diff --git a/src/ui/activities/setup/actions.rs b/src/ui/activities/setup/actions.rs index 6c85cd1..971b37b 100644 --- a/src/ui/activities/setup/actions.rs +++ b/src/ui/activities/setup/actions.rs @@ -366,7 +366,7 @@ impl SetupActivity { .get_color(&Id::Theme(IdTheme::StatusSync)) .map_err(|_| Id::Theme(IdTheme::StatusSync))?; // Update theme - let mut theme: &mut Theme = self.theme_mut(); + let theme = self.theme_mut(); theme.auth_address = auth_address; theme.auth_bookmarks = auth_bookmarks; theme.auth_password = auth_password; diff --git a/src/utils/parser.rs b/src/utils/parser.rs index 079e6e3..e3ec11e 100644 --- a/src/utils/parser.rs +++ b/src/utils/parser.rs @@ -73,7 +73,7 @@ static REMOTE_SMB_OPT_REGEX: Lazy = lazy_regex!( * - group 3: share * - group 4: remote-dir? */ -#[cfg(windows)] +#[cfg(smb_windows)] static REMOTE_SMB_OPT_REGEX: Lazy = lazy_regex!(r"(?:([^@]+)@)?(?:([^:\\]+))(?:\\([^\\]+))?(?:(\\.+))?"); @@ -171,7 +171,7 @@ fn parse_remote_opt_protocol( let protocol = match protocol { Some(Ok(protocol)) => protocol, Some(Err(err)) => return Err(err), - #[cfg(windows)] + #[cfg(smb_windows)] None if groups.get(2).is_some() => FileTransferProtocol::Smb, None => default, }; @@ -295,7 +295,7 @@ fn parse_smb_remote_opts(s: &str) -> Result { } } -#[cfg(windows)] +#[cfg(smb_windows)] fn parse_smb_remote_opts(s: &str) -> Result { match REMOTE_SMB_OPT_REGEX.captures(s) { Some(groups) => { @@ -639,7 +639,7 @@ mod tests { } #[test] - #[cfg(windows)] + #[cfg(smb_windows)] fn should_parse_smb_address() { let result = parse_remote_opt(&String::from("\\\\myserver\\myshare")) .ok() @@ -652,7 +652,7 @@ mod tests { } #[test] - #[cfg(windows)] + #[cfg(smb_windows)] fn should_parse_smb_address_with_opts() { let result = parse_remote_opt(&String::from("\\\\omar@myserver\\myshare\\path")) .ok()