fix: cfg unix forbidden in rust .82
Install.sh / build (push) Waiting to run
Linux / build (push) Waiting to run
MacOS / build (push) Waiting to run
Windows / build (push) Waiting to run

This commit is contained in:
veeso
2024-10-21 10:32:50 +02:00
parent 11559d0962
commit 69f821baef
22 changed files with 95 additions and 95 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Platforms // Platforms
macos: { target_os = "macos" }, macos: { target_os = "macos" },
linux: { target_os = "linux" }, linux: { target_os = "linux" },
unix: { target_family = "unix" }, posix: { target_family = "unix" },
windows: { target_family = "windows" }, windows: { target_family = "windows" },
// exclusive features // exclusive features
smb: { all(feature = "smb", not( macos )) }, smb: { all(feature = "smb", not( macos )) },
+3 -3
View File
@@ -180,7 +180,7 @@ mod test {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_should_make_remote_args_from_two_remotes_and_local_dir() { fn test_should_make_remote_args_from_two_remotes_and_local_dir() {
let args = Args { let args = Args {
positional: vec![ positional: vec![
@@ -224,7 +224,7 @@ mod test {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_should_make_remote_args_from_two_bookmarks_and_local_dir() { fn test_should_make_remote_args_from_two_bookmarks_and_local_dir() {
let args = Args { let args = Args {
bookmark: vec!["foo".to_string(), "bar".to_string()], bookmark: vec!["foo".to_string(), "bar".to_string()],
@@ -254,7 +254,7 @@ mod test {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_should_make_remote_args_from_one_bookmark_and_one_remote_with_local_dir() { fn test_should_make_remote_args_from_one_bookmark_and_one_remote_with_local_dir() {
let args = Args { let args = Args {
positional: vec!["scp://host1".to_string(), "/home".to_string()], positional: vec!["scp://host1".to_string(), "/home".to_string()],
+3 -3
View File
@@ -108,7 +108,7 @@ impl From<FileTransferParams> for Bookmark {
smb: Some(SmbParams::from(params.clone())), smb: Some(SmbParams::from(params.clone())),
protocol, protocol,
address: Some(params.address), address: Some(params.address),
#[cfg(unix)] #[cfg(posix)]
port: Some(params.port), port: Some(params.port),
#[cfg(windows)] #[cfg(windows)]
port: None, port: None,
@@ -159,7 +159,7 @@ impl From<Bookmark> for FileTransferParams {
let params = KubeProtocolParams::from(params); let params = KubeProtocolParams::from(params);
Self::new(bookmark.protocol, ProtocolParams::Kube(params)) Self::new(bookmark.protocol, ProtocolParams::Kube(params))
} }
#[cfg(unix)] #[cfg(posix)]
FileTransferProtocol::Smb => { FileTransferProtocol::Smb => {
let params = TransferSmbParams::new( let params = TransferSmbParams::new(
bookmark.address.unwrap_or_default(), bookmark.address.unwrap_or_default(),
@@ -521,7 +521,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn should_get_ftparams_from_smb_bookmark() { fn should_get_ftparams_from_smb_bookmark() {
let bookmark: Bookmark = Bookmark { let bookmark: Bookmark = Bookmark {
protocol: FileTransferProtocol::Smb, protocol: FileTransferProtocol::Smb,
+1 -1
View File
@@ -9,7 +9,7 @@ pub struct SmbParams {
pub workgroup: Option<String>, pub workgroup: Option<String>,
} }
#[cfg(unix)] #[cfg(posix)]
impl From<TransferSmbParams> for SmbParams { impl From<TransferSmbParams> for SmbParams {
fn from(params: TransferSmbParams) -> Self { fn from(params: TransferSmbParams) -> Self {
Self { Self {
+3 -3
View File
@@ -422,14 +422,14 @@ mod tests {
let host = hosts.bookmarks.get("smb").unwrap(); let host = hosts.bookmarks.get("smb").unwrap();
assert_eq!(host.address.as_deref().unwrap(), "localhost"); assert_eq!(host.address.as_deref().unwrap(), "localhost");
assert_eq!(host.port.unwrap(), 445); assert_eq!(host.port.unwrap(), 445);
#[cfg(unix)] #[cfg(posix)]
assert_eq!(host.username.as_deref().unwrap(), "test"); assert_eq!(host.username.as_deref().unwrap(), "test");
#[cfg(unix)] #[cfg(posix)]
assert_eq!(host.password.as_deref().unwrap(), "test"); assert_eq!(host.password.as_deref().unwrap(), "test");
let smb = host.smb.as_ref().unwrap(); let smb = host.smb.as_ref().unwrap();
assert_eq!(smb.share.as_str(), "temp"); assert_eq!(smb.share.as_str(), "temp");
#[cfg(unix)] #[cfg(posix)]
assert_eq!(smb.workgroup.as_deref().unwrap(), "test"); assert_eq!(smb.workgroup.as_deref().unwrap(), "test");
} }
+11 -11
View File
@@ -11,7 +11,7 @@ use bytesize::ByteSize;
use lazy_regex::{Lazy, Regex}; use lazy_regex::{Lazy, Regex};
use remotefs::File; use remotefs::File;
use unicode_width::UnicodeWidthStr; use unicode_width::UnicodeWidthStr;
#[cfg(unix)] #[cfg(posix)]
use uzers::{get_group_by_gid, get_user_by_uid}; use uzers::{get_group_by_gid, get_user_by_uid};
use crate::utils::fmt::{fmt_path_elide, fmt_pex, fmt_time}; use crate::utils::fmt::{fmt_path_elide, fmt_pex, fmt_time};
@@ -211,7 +211,7 @@ impl Formatter {
_fmt_extra: Option<&String>, _fmt_extra: Option<&String>,
) -> String { ) -> String {
// Get username // Get username
#[cfg(unix)] #[cfg(posix)]
let group: String = match fsentry.metadata().gid { let group: String = match fsentry.metadata().gid {
Some(gid) => match get_group_by_gid(gid) { Some(gid) => match get_group_by_gid(gid) {
Some(user) => user.name().to_string_lossy().to_string(), Some(user) => user.name().to_string_lossy().to_string(),
@@ -420,7 +420,7 @@ impl Formatter {
_fmt_extra: Option<&String>, _fmt_extra: Option<&String>,
) -> String { ) -> String {
// Get username // Get username
#[cfg(unix)] #[cfg(posix)]
let username: String = match fsentry.metadata().uid { let username: String = match fsentry.metadata().uid {
Some(uid) => match get_user_by_uid(uid) { Some(uid) => match get_user_by_uid(uid) {
Some(user) => user.name().to_string_lossy().to_string(), Some(user) => user.name().to_string_lossy().to_string(),
@@ -592,7 +592,7 @@ mod tests {
mode: Some(UnixPex::from(0o644)), mode: Some(UnixPex::from(0o644)),
}, },
}; };
#[cfg(unix)] #[cfg(posix)]
assert_eq!( assert_eq!(
formatter.fmt(&entry), formatter.fmt(&entry),
format!( format!(
@@ -623,7 +623,7 @@ mod tests {
mode: Some(UnixPex::from(0o644)), mode: Some(UnixPex::from(0o644)),
}, },
}; };
#[cfg(unix)] #[cfg(posix)]
assert_eq!( assert_eq!(
formatter.fmt(&entry), formatter.fmt(&entry),
format!( format!(
@@ -654,7 +654,7 @@ mod tests {
mode: None, mode: None,
}, },
}; };
#[cfg(unix)] #[cfg(posix)]
assert_eq!( assert_eq!(
formatter.fmt(&entry), formatter.fmt(&entry),
format!( format!(
@@ -685,7 +685,7 @@ mod tests {
mode: None, mode: None,
}, },
}; };
#[cfg(unix)] #[cfg(posix)]
assert_eq!( assert_eq!(
formatter.fmt(&entry), formatter.fmt(&entry),
format!( format!(
@@ -723,7 +723,7 @@ mod tests {
mode: Some(UnixPex::from(0o755)), mode: Some(UnixPex::from(0o755)),
}, },
}; };
#[cfg(unix)] #[cfg(posix)]
assert_eq!( assert_eq!(
formatter.fmt(&entry), formatter.fmt(&entry),
format!( format!(
@@ -754,7 +754,7 @@ mod tests {
mode: None, mode: None,
}, },
}; };
#[cfg(unix)] #[cfg(posix)]
assert_eq!( assert_eq!(
formatter.fmt(&entry), formatter.fmt(&entry),
format!( format!(
@@ -864,7 +864,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn should_fmt_path() { fn should_fmt_path() {
let t: SystemTime = SystemTime::now(); let t: SystemTime = SystemTime::now();
let entry = File { let entry = File {
@@ -896,7 +896,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn should_fmt_utf8_path() { fn should_fmt_utf8_path() {
let t: SystemTime = SystemTime::now(); let t: SystemTime = SystemTime::now();
let entry = File { let entry = File {
+1 -1
View File
@@ -519,7 +519,7 @@ mod tests {
mode: Some(UnixPex::from(0o644)), mode: Some(UnixPex::from(0o644)),
}, },
}; };
#[cfg(unix)] #[cfg(posix)]
assert_eq!( assert_eq!(
explorer.fmt_file(&entry), explorer.fmt_file(&entry),
format!( format!(
+1 -1
View File
@@ -362,7 +362,7 @@ mod test {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn set_default_secret_smb() { fn set_default_secret_smb() {
let mut params = FileTransferParams::new( let mut params = FileTransferParams::new(
FileTransferProtocol::Scp, FileTransferProtocol::Scp,
+12 -12
View File
@@ -2,12 +2,12 @@
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SmbParams { pub struct SmbParams {
pub address: String, pub address: String,
#[cfg(unix)] #[cfg(posix)]
pub port: u16, pub port: u16,
pub share: String, pub share: String,
pub username: Option<String>, pub username: Option<String>,
pub password: Option<String>, pub password: Option<String>,
#[cfg(unix)] #[cfg(posix)]
pub workgroup: Option<String>, pub workgroup: Option<String>,
} }
@@ -18,17 +18,17 @@ impl SmbParams {
pub fn new<S: AsRef<str>>(address: S, share: S) -> Self { pub fn new<S: AsRef<str>>(address: S, share: S) -> Self {
Self { Self {
address: address.as_ref().to_string(), address: address.as_ref().to_string(),
#[cfg(unix)] #[cfg(posix)]
port: 445, port: 445,
share: share.as_ref().to_string(), share: share.as_ref().to_string(),
username: None, username: None,
password: None, password: None,
#[cfg(unix)] #[cfg(posix)]
workgroup: None, workgroup: None,
} }
} }
#[cfg(unix)] #[cfg(posix)]
pub fn port(mut self, port: u16) -> Self { pub fn port(mut self, port: u16) -> Self {
self.port = port; self.port = port;
self self
@@ -44,7 +44,7 @@ impl SmbParams {
self self
} }
#[cfg(unix)] #[cfg(posix)]
pub fn workgroup(mut self, workgroup: Option<impl ToString>) -> Self { pub fn workgroup(mut self, workgroup: Option<impl ToString>) -> Self {
self.workgroup = workgroup.map(|x| x.to_string()); self.workgroup = workgroup.map(|x| x.to_string());
self self
@@ -57,7 +57,7 @@ impl SmbParams {
} }
/// Set password /// Set password
#[cfg(unix)] #[cfg(posix)]
pub fn set_default_secret(&mut self, secret: String) { pub fn set_default_secret(&mut self, secret: String) {
self.password = Some(secret); self.password = Some(secret);
} }
@@ -78,20 +78,20 @@ mod test {
let params = SmbParams::new("localhost", "temp"); let params = SmbParams::new("localhost", "temp");
assert_eq!(&params.address, "localhost"); assert_eq!(&params.address, "localhost");
#[cfg(unix)] #[cfg(posix)]
assert_eq!(params.port, 445); assert_eq!(params.port, 445);
assert_eq!(&params.share, "temp"); assert_eq!(&params.share, "temp");
#[cfg(unix)] #[cfg(posix)]
assert!(params.username.is_none()); assert!(params.username.is_none());
#[cfg(unix)] #[cfg(posix)]
assert!(params.password.is_none()); assert!(params.password.is_none());
#[cfg(unix)] #[cfg(posix)]
assert!(params.workgroup.is_none()); assert!(params.workgroup.is_none());
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn should_init_smb_params_with_optionals() { fn should_init_smb_params_with_optionals() {
let params = SmbParams::new("localhost", "temp") let params = SmbParams::new("localhost", "temp")
.port(3456) .port(3456)
+25 -25
View File
@@ -1,6 +1,6 @@
use std::fs::{self, OpenOptions}; use std::fs::{self, OpenOptions};
use std::io::{Read, Write}; use std::io::{Read, Write};
#[cfg(unix)] #[cfg(posix)]
use std::os::unix::fs::PermissionsExt as _; use std::os::unix::fs::PermissionsExt as _;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@@ -385,7 +385,7 @@ impl HostBridge for Localhost {
filetime::set_file_atime(path, atime) filetime::set_file_atime(path, atime)
.map_err(|e| HostError::new(HostErrorType::FileNotAccessible, Some(e), path))?; .map_err(|e| HostError::new(HostErrorType::FileNotAccessible, Some(e), path))?;
} }
#[cfg(unix)] #[cfg(posix)]
if let Some(mode) = metadata.mode { if let Some(mode) = metadata.mode {
self.chmod(path, mode)?; self.chmod(path, mode)?;
} }
@@ -417,7 +417,7 @@ impl HostBridge for Localhost {
} }
} }
#[cfg(unix)] #[cfg(posix)]
fn symlink(&mut self, src: &Path, dst: &Path) -> HostResult<()> { fn symlink(&mut self, src: &Path, dst: &Path) -> HostResult<()> {
let src = self.to_path(src); let src = self.to_path(src);
std::os::unix::fs::symlink(dst, src.as_path()).map_err(|e| { std::os::unix::fs::symlink(dst, src.as_path()).map_err(|e| {
@@ -438,7 +438,7 @@ impl HostBridge for Localhost {
Err(HostError::from(HostErrorType::NotImplemented)) Err(HostError::from(HostErrorType::NotImplemented))
} }
#[cfg(unix)] #[cfg(posix)]
fn chmod(&mut self, path: &std::path::Path, pex: UnixPex) -> HostResult<()> { fn chmod(&mut self, path: &std::path::Path, pex: UnixPex) -> HostResult<()> {
let path: PathBuf = self.to_path(path); let path: PathBuf = self.to_path(path);
// Get metadta // Get metadta
@@ -553,19 +553,19 @@ impl HostBridge for Localhost {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
#[cfg(unix)] #[cfg(posix)]
use std::fs::File as StdFile; use std::fs::File as StdFile;
#[cfg(unix)] #[cfg(posix)]
use std::io::Write; use std::io::Write;
use std::ops::AddAssign; use std::ops::AddAssign;
#[cfg(unix)] #[cfg(posix)]
use std::os::unix::fs::{symlink, PermissionsExt}; use std::os::unix::fs::{symlink, PermissionsExt};
use std::time::{Duration, SystemTime}; use std::time::{Duration, SystemTime};
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use super::*; use super::*;
#[cfg(unix)] #[cfg(posix)]
use crate::utils::test_helpers::make_fsentry; use crate::utils::test_helpers::make_fsentry;
use crate::utils::test_helpers::{create_sample_file, make_file_at}; use crate::utils::test_helpers::{create_sample_file, make_file_at};
@@ -578,7 +578,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_host_localhost_new() { fn test_host_localhost_new() {
let host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap(); let host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
assert_eq!(host.wrkdir, PathBuf::from("/dev")); assert_eq!(host.wrkdir, PathBuf::from("/dev"));
@@ -614,14 +614,14 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_host_localhost_pwd() { fn test_host_localhost_pwd() {
let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap(); let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
assert_eq!(host.pwd().unwrap(), PathBuf::from("/dev")); assert_eq!(host.pwd().unwrap(), PathBuf::from("/dev"));
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_host_localhost_change_dir() { fn test_host_localhost_change_dir() {
let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap(); let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
let new_dir: PathBuf = PathBuf::from("/dev"); let new_dir: PathBuf = PathBuf::from("/dev");
@@ -637,7 +637,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
#[should_panic] #[should_panic]
fn test_host_localhost_change_dir_failed() { fn test_host_localhost_change_dir_failed() {
let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap(); let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
@@ -646,7 +646,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_host_localhost_open_read() { fn test_host_localhost_open_read() {
let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap(); let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
// Create temp file // Create temp file
@@ -655,7 +655,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
#[should_panic] #[should_panic]
fn test_host_localhost_open_read_err_no_such_file() { fn test_host_localhost_open_read_err_no_such_file() {
let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap(); let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
@@ -676,7 +676,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_host_localhost_open_write() { fn test_host_localhost_open_write() {
let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap(); let mut host: Localhost = Localhost::new(PathBuf::from("/dev")).ok().unwrap();
// Create temp file // Create temp file
@@ -695,7 +695,7 @@ mod tests {
assert!(host.create_file(file.path(), &Metadata::default()).is_err()); assert!(host.create_file(file.path(), &Metadata::default()).is_err());
} }
#[cfg(unix)] #[cfg(posix)]
#[test] #[test]
fn test_host_localhost_symlinks() { fn test_host_localhost_symlinks() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap(); let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
@@ -733,7 +733,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_host_localhost_mkdir() { fn test_host_localhost_mkdir() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap(); let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
let mut host: Localhost = Localhost::new(PathBuf::from(tmpdir.path())).ok().unwrap(); let mut host: Localhost = Localhost::new(PathBuf::from(tmpdir.path())).ok().unwrap();
@@ -758,7 +758,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_host_localhost_remove() { fn test_host_localhost_remove() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap(); let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
// Create sample file // Create sample file
@@ -787,7 +787,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_host_localhost_rename() { fn test_host_localhost_rename() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap(); let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
// Create sample file // Create sample file
@@ -840,7 +840,7 @@ mod tests {
assert_eq!(new_metadata.metadata().modified, Some(new_mtime)); assert_eq!(new_metadata.metadata().modified, Some(new_mtime));
} }
#[cfg(unix)] #[cfg(posix)]
#[test] #[test]
fn test_host_chmod() { fn test_host_chmod() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap(); let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
@@ -859,7 +859,7 @@ mod tests {
.is_err()); .is_err());
} }
#[cfg(unix)] #[cfg(posix)]
#[test] #[test]
fn test_host_copy_file_absolute() { fn test_host_copy_file_absolute() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap(); let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
@@ -889,7 +889,7 @@ mod tests {
.is_err()); .is_err());
} }
#[cfg(unix)] #[cfg(posix)]
#[test] #[test]
fn test_host_copy_file_relative() { fn test_host_copy_file_relative() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap(); let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
@@ -911,7 +911,7 @@ mod tests {
assert_eq!(host.files.len(), 2); assert_eq!(host.files.len(), 2);
} }
#[cfg(unix)] #[cfg(posix)]
#[test] #[test]
fn test_host_copy_directory_absolute() { fn test_host_copy_directory_absolute() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap(); let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
@@ -942,7 +942,7 @@ mod tests {
assert!(host.stat(test_file_path.as_path()).is_ok()); assert!(host.stat(test_file_path.as_path()).is_ok());
} }
#[cfg(unix)] #[cfg(posix)]
#[test] #[test]
fn test_host_copy_directory_relative() { fn test_host_copy_directory_relative() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap(); let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
@@ -980,7 +980,7 @@ mod tests {
assert!(host.exec("echo 5").ok().unwrap().as_str().contains("5")); assert!(host.exec("echo 5").ok().unwrap().as_str().contains("5"));
} }
#[cfg(unix)] #[cfg(posix)]
#[test] #[test]
fn should_create_symlink() { fn should_create_symlink() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap(); let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
+1 -1
View File
@@ -385,7 +385,7 @@ mod test {
/* /*
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn should_poll_file_moved() { fn should_poll_file_moved() {
let mut watcher = FsWatcher::init(Duration::from_millis(100)).unwrap(); let mut watcher = FsWatcher::init(Duration::from_millis(100)).unwrap();
let tempdir = TempDir::new().unwrap(); let tempdir = TempDir::new().unwrap();
+2 -2
View File
@@ -280,12 +280,12 @@ impl AuthActivity {
fn load_bookmark_smb_into_gui(&mut self, form_tab: FormTab, params: SmbParams) { fn load_bookmark_smb_into_gui(&mut self, form_tab: FormTab, params: SmbParams) {
self.mount_address(form_tab, params.address.as_str()); self.mount_address(form_tab, params.address.as_str());
#[cfg(unix)] #[cfg(posix)]
self.mount_port(form_tab, params.port); self.mount_port(form_tab, params.port);
self.mount_username(form_tab, params.username.as_deref().unwrap_or("")); self.mount_username(form_tab, params.username.as_deref().unwrap_or(""));
self.mount_password(form_tab, params.password.as_deref().unwrap_or("")); self.mount_password(form_tab, params.password.as_deref().unwrap_or(""));
self.mount_smb_share(form_tab, &params.share); self.mount_smb_share(form_tab, &params.share);
#[cfg(unix)] #[cfg(posix)]
self.mount_smb_workgroup(form_tab, params.workgroup.as_deref().unwrap_or("")); self.mount_smb_workgroup(form_tab, params.workgroup.as_deref().unwrap_or(""));
} }
+3 -3
View File
@@ -952,14 +952,14 @@ impl Component<Msg, NoUserEvent> for InputSmbShare {
} }
} }
#[cfg(unix)] #[cfg(posix)]
#[derive(MockComponent)] #[derive(MockComponent)]
pub struct InputSmbWorkgroup { pub struct InputSmbWorkgroup {
component: Input, component: Input,
form_tab: FormTab, form_tab: FormTab,
} }
#[cfg(unix)] #[cfg(posix)]
impl InputSmbWorkgroup { impl InputSmbWorkgroup {
pub fn new(host: &str, form_tab: FormTab, color: Color) -> Self { pub fn new(host: &str, form_tab: FormTab, color: Color) -> Self {
Self { Self {
@@ -978,7 +978,7 @@ impl InputSmbWorkgroup {
} }
} }
#[cfg(unix)] #[cfg(posix)]
impl Component<Msg, NoUserEvent> for InputSmbWorkgroup { impl Component<Msg, NoUserEvent> for InputSmbWorkgroup {
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> { fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
let on_key_down = match self.form_tab { let on_key_down = match self.form_tab {
+1 -1
View File
@@ -13,7 +13,7 @@ pub use bookmarks::{
BookmarkName, BookmarkSavePassword, BookmarksList, DeleteBookmarkPopup, DeleteRecentPopup, BookmarkName, BookmarkSavePassword, BookmarksList, DeleteBookmarkPopup, DeleteRecentPopup,
RecentsList, RecentsList,
}; };
#[cfg(unix)] #[cfg(posix)]
pub use form::InputSmbWorkgroup; pub use form::InputSmbWorkgroup;
pub use form::{ pub use form::{
HostBridgeProtocolRadio, InputAddress, InputKubeClientCert, InputKubeClientKey, HostBridgeProtocolRadio, InputAddress, InputKubeClientCert, InputKubeClientKey,
+1 -1
View File
@@ -151,7 +151,7 @@ impl AuthActivity {
if params.address.is_empty() { if params.address.is_empty() {
return Err("Invalid address"); return Err("Invalid address");
} }
#[cfg(unix)] #[cfg(posix)]
if params.port == 0 { if params.port == 0 {
return Err("Invalid port"); return Err("Invalid port");
} }
+3 -3
View File
@@ -93,7 +93,7 @@ pub enum AuthFormId {
S3SecurityToken, S3SecurityToken,
S3SessionToken, S3SessionToken,
SmbShare, SmbShare,
#[cfg(unix)] #[cfg(posix)]
SmbWorkgroup, SmbWorkgroup,
Username, Username,
WebDAVUri, WebDAVUri,
@@ -193,9 +193,9 @@ pub enum UiAuthFormMsg {
S3SessionTokenBlurUp, S3SessionTokenBlurUp,
SmbShareBlurDown, SmbShareBlurDown,
SmbShareBlurUp, SmbShareBlurUp,
#[cfg(unix)] #[cfg(posix)]
SmbWorkgroupDown, SmbWorkgroupDown,
#[cfg(unix)] #[cfg(posix)]
SmbWorkgroupUp, SmbWorkgroupUp,
UsernameBlurDown, UsernameBlurDown,
UsernameBlurUp, UsernameBlurUp,
+8 -8
View File
@@ -269,7 +269,7 @@ impl AuthActivity {
.active(match self.host_bridge_input_mask() { .active(match self.host_bridge_input_mask() {
InputMask::Localhost => unreachable!(), InputMask::Localhost => unreachable!(),
InputMask::Generic => &Id::HostBridge(AuthFormId::RemoteDirectory), InputMask::Generic => &Id::HostBridge(AuthFormId::RemoteDirectory),
#[cfg(unix)] #[cfg(posix)]
InputMask::Smb => &Id::HostBridge(AuthFormId::SmbWorkgroup), InputMask::Smb => &Id::HostBridge(AuthFormId::SmbWorkgroup),
#[cfg(windows)] #[cfg(windows)]
InputMask::Smb => &Id::HostBridge(AuthFormId::RemoteDirectory), InputMask::Smb => &Id::HostBridge(AuthFormId::RemoteDirectory),
@@ -285,7 +285,7 @@ impl AuthActivity {
.active(match self.remote_input_mask() { .active(match self.remote_input_mask() {
InputMask::Localhost => unreachable!(), InputMask::Localhost => unreachable!(),
InputMask::Generic => &Id::Remote(AuthFormId::RemoteDirectory), InputMask::Generic => &Id::Remote(AuthFormId::RemoteDirectory),
#[cfg(unix)] #[cfg(posix)]
InputMask::Smb => &Id::Remote(AuthFormId::SmbWorkgroup), InputMask::Smb => &Id::Remote(AuthFormId::SmbWorkgroup),
#[cfg(windows)] #[cfg(windows)]
InputMask::Smb => &Id::Remote(AuthFormId::RemoteDirectory), InputMask::Smb => &Id::Remote(AuthFormId::RemoteDirectory),
@@ -400,7 +400,7 @@ impl AuthActivity {
.active(match self.host_bridge_input_mask() { .active(match self.host_bridge_input_mask() {
InputMask::Localhost => unreachable!(), InputMask::Localhost => unreachable!(),
InputMask::Generic => &Id::HostBridge(AuthFormId::Password), InputMask::Generic => &Id::HostBridge(AuthFormId::Password),
#[cfg(unix)] #[cfg(posix)]
InputMask::Smb => &Id::HostBridge(AuthFormId::SmbWorkgroup), InputMask::Smb => &Id::HostBridge(AuthFormId::SmbWorkgroup),
#[cfg(windows)] #[cfg(windows)]
InputMask::Smb => &Id::HostBridge(AuthFormId::Password), InputMask::Smb => &Id::HostBridge(AuthFormId::Password),
@@ -416,7 +416,7 @@ impl AuthActivity {
.active(match self.remote_input_mask() { .active(match self.remote_input_mask() {
InputMask::Localhost => unreachable!(), InputMask::Localhost => unreachable!(),
InputMask::Generic => &Id::Remote(AuthFormId::Password), InputMask::Generic => &Id::Remote(AuthFormId::Password),
#[cfg(unix)] #[cfg(posix)]
InputMask::Smb => &Id::Remote(AuthFormId::SmbWorkgroup), InputMask::Smb => &Id::Remote(AuthFormId::SmbWorkgroup),
#[cfg(windows)] #[cfg(windows)]
InputMask::Smb => &Id::Remote(AuthFormId::Password), InputMask::Smb => &Id::Remote(AuthFormId::Password),
@@ -760,28 +760,28 @@ impl AuthActivity {
}; };
assert!(self.app.active(id).is_ok()); assert!(self.app.active(id).is_ok());
} }
#[cfg(unix)] #[cfg(posix)]
UiMsg::HostBridge(UiAuthFormMsg::SmbWorkgroupDown) => { UiMsg::HostBridge(UiAuthFormMsg::SmbWorkgroupDown) => {
assert!(self assert!(self
.app .app
.active(&Id::HostBridge(AuthFormId::RemoteDirectory)) .active(&Id::HostBridge(AuthFormId::RemoteDirectory))
.is_ok()); .is_ok());
} }
#[cfg(unix)] #[cfg(posix)]
UiMsg::Remote(UiAuthFormMsg::SmbWorkgroupDown) => { UiMsg::Remote(UiAuthFormMsg::SmbWorkgroupDown) => {
assert!(self assert!(self
.app .app
.active(&Id::Remote(AuthFormId::RemoteDirectory)) .active(&Id::Remote(AuthFormId::RemoteDirectory))
.is_ok()); .is_ok());
} }
#[cfg(unix)] #[cfg(posix)]
UiMsg::HostBridge(UiAuthFormMsg::SmbWorkgroupUp) => { UiMsg::HostBridge(UiAuthFormMsg::SmbWorkgroupUp) => {
assert!(self assert!(self
.app .app
.active(&Id::HostBridge(AuthFormId::Password)) .active(&Id::HostBridge(AuthFormId::Password))
.is_ok()); .is_ok());
} }
#[cfg(unix)] #[cfg(posix)]
UiMsg::Remote(UiAuthFormMsg::SmbWorkgroupUp) => { UiMsg::Remote(UiAuthFormMsg::SmbWorkgroupUp) => {
assert!(self.app.active(&Id::Remote(AuthFormId::Password)).is_ok()); assert!(self.app.active(&Id::Remote(AuthFormId::Password)).is_ok());
} }
+8 -8
View File
@@ -69,7 +69,7 @@ impl AuthActivity {
self.mount_kube_namespace(FormTab::HostBridge, ""); self.mount_kube_namespace(FormTab::HostBridge, "");
self.mount_kube_username(FormTab::HostBridge, ""); self.mount_kube_username(FormTab::HostBridge, "");
self.mount_smb_share(FormTab::HostBridge, ""); self.mount_smb_share(FormTab::HostBridge, "");
#[cfg(unix)] #[cfg(posix)]
self.mount_smb_workgroup(FormTab::HostBridge, ""); self.mount_smb_workgroup(FormTab::HostBridge, "");
self.mount_webdav_uri(FormTab::HostBridge, ""); self.mount_webdav_uri(FormTab::HostBridge, "");
@@ -102,7 +102,7 @@ impl AuthActivity {
self.mount_kube_namespace(FormTab::Remote, ""); self.mount_kube_namespace(FormTab::Remote, "");
self.mount_kube_username(FormTab::Remote, ""); self.mount_kube_username(FormTab::Remote, "");
self.mount_smb_share(FormTab::Remote, ""); self.mount_smb_share(FormTab::Remote, "");
#[cfg(unix)] #[cfg(posix)]
self.mount_smb_workgroup(FormTab::Remote, ""); self.mount_smb_workgroup(FormTab::Remote, "");
self.mount_webdav_uri(FormTab::Remote, ""); self.mount_webdav_uri(FormTab::Remote, "");
@@ -1042,7 +1042,7 @@ impl AuthActivity {
.is_ok()); .is_ok());
} }
#[cfg(unix)] #[cfg(posix)]
pub(super) fn mount_smb_workgroup(&mut self, form_tab: FormTab, workgroup: &str) { pub(super) fn mount_smb_workgroup(&mut self, form_tab: FormTab, workgroup: &str) {
let color = self.theme().auth_address; let color = self.theme().auth_address;
let id = Self::form_tab_id(form_tab, AuthFormId::SmbWorkgroup); let id = Self::form_tab_id(form_tab, AuthFormId::SmbWorkgroup);
@@ -1130,7 +1130,7 @@ impl AuthActivity {
} }
/// Collect s3 input values from view /// Collect s3 input values from view
#[cfg(unix)] #[cfg(posix)]
pub(super) fn get_smb_params_input(&self, form_tab: FormTab) -> SmbParams { pub(super) fn get_smb_params_input(&self, form_tab: FormTab) -> SmbParams {
let share: String = self.get_input_smb_share(form_tab); let share: String = self.get_input_smb_share(form_tab);
let workgroup: Option<String> = self.get_input_smb_workgroup(form_tab); let workgroup: Option<String> = self.get_input_smb_workgroup(form_tab);
@@ -1394,7 +1394,7 @@ impl AuthActivity {
} }
} }
#[cfg(unix)] #[cfg(posix)]
pub(super) fn get_input_smb_workgroup(&self, form_tab: FormTab) -> Option<String> { pub(super) fn get_input_smb_workgroup(&self, form_tab: FormTab) -> Option<String> {
match self match self
.app .app
@@ -1494,7 +1494,7 @@ impl AuthActivity {
.unwrap_or_default() .unwrap_or_default()
) )
} }
#[cfg(unix)] #[cfg(posix)]
ProtocolParams::Smb(params) => { ProtocolParams::Smb(params) => {
let username: String = match params.username { let username: String = match params.username {
None => String::default(), None => String::default(),
@@ -1749,7 +1749,7 @@ impl AuthActivity {
} }
} }
#[cfg(unix)] #[cfg(posix)]
fn get_host_bridge_smb_view(&self) -> [Id; 4] { fn get_host_bridge_smb_view(&self) -> [Id; 4] {
match self.app.focus() { match self.app.focus() {
Some( Some(
@@ -1796,7 +1796,7 @@ impl AuthActivity {
} }
} }
#[cfg(unix)] #[cfg(posix)]
fn get_remote_smb_view(&self) -> [Id; 4] { fn get_remote_smb_view(&self) -> [Id; 4] {
match self.app.focus() { match self.app.focus() {
Some( Some(
@@ -16,7 +16,7 @@ use tuirealm::props::{
Alignment, BorderSides, BorderType, Borders, Color, InputType, Style, TableBuilder, TextSpan, Alignment, BorderSides, BorderType, Borders, Color, InputType, Style, TableBuilder, TextSpan,
}; };
use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue}; use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
#[cfg(unix)] #[cfg(posix)]
use uzers::{get_group_by_gid, get_user_by_uid}; use uzers::{get_group_by_gid, get_user_by_uid};
pub use self::chmod::ChmodPopup; pub use self::chmod::ChmodPopup;
@@ -533,7 +533,7 @@ impl FileInfoPopup {
.add_col(TextSpan::from("Last access time: ")) .add_col(TextSpan::from("Last access time: "))
.add_col(TextSpan::new(atime.as_str()).fg(Color::LightRed)); .add_col(TextSpan::new(atime.as_str()).fg(Color::LightRed));
// User // User
#[cfg(unix)] #[cfg(posix)]
let username: String = match file.metadata().uid { let username: String = match file.metadata().uid {
Some(uid) => match get_user_by_uid(uid) { Some(uid) => match get_user_by_uid(uid) {
Some(user) => user.name().to_string_lossy().to_string(), Some(user) => user.name().to_string_lossy().to_string(),
@@ -544,7 +544,7 @@ impl FileInfoPopup {
#[cfg(windows)] #[cfg(windows)]
let username: String = format!("{}", file.metadata().uid.unwrap_or(0)); let username: String = format!("{}", file.metadata().uid.unwrap_or(0));
// Group // Group
#[cfg(unix)] #[cfg(posix)]
let group: String = match file.metadata().gid { let group: String = match file.metadata().gid {
Some(gid) => match get_group_by_gid(gid) { Some(gid) => match get_group_by_gid(gid) {
Some(group) => group.name().to_string_lossy().to_string(), Some(group) => group.name().to_string_lossy().to_string(),
@@ -365,7 +365,7 @@ mod test {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_should_suggest_absolute_path() { fn test_should_suggest_absolute_path() {
let mut states = OwnStates { let mut states = OwnStates {
files: vec![ files: vec![
+2 -2
View File
@@ -494,9 +494,9 @@ impl FileTransferActivity {
} }
UiMsg::ShowChmodPopup => { UiMsg::ShowChmodPopup => {
let selected_file = match self.browser.tab() { let selected_file = match self.browser.tab() {
#[cfg(unix)] #[cfg(posix)]
FileExplorerTab::HostBridge => self.get_local_selected_entries(), FileExplorerTab::HostBridge => self.get_local_selected_entries(),
#[cfg(unix)] #[cfg(posix)]
FileExplorerTab::FindHostBridge => self.get_found_selected_entries(), FileExplorerTab::FindHostBridge => self.get_found_selected_entries(),
FileExplorerTab::Remote => self.get_remote_selected_entries(), FileExplorerTab::Remote => self.get_remote_selected_entries(),
FileExplorerTab::FindRemote => self.get_found_selected_entries(), FileExplorerTab::FindRemote => self.get_found_selected_entries(),
+1 -1
View File
@@ -308,7 +308,7 @@ mod tests {
} }
#[test] #[test]
#[cfg(unix)] #[cfg(posix)]
fn test_utils_fmt_path_elide() { fn test_utils_fmt_path_elide() {
let p: &Path = Path::new("/develop/pippo"); let p: &Path = Path::new("/develop/pippo");
// Under max size // Under max size