From 32ab0267fbe73a97cc417419398b8bb5215d60db Mon Sep 17 00:00:00 2001 From: veeso Date: Mon, 23 Aug 2021 17:18:27 +0200 Subject: [PATCH] Removed unused readonly attribute for FsEntry --- src/filetransfer/ftp_transfer.rs | 21 ++++++++------------- src/filetransfer/scp_transfer.rs | 23 ++++++++--------------- src/filetransfer/sftp_transfer.rs | 20 ++++++++------------ src/fs/explorer/formatter.rs | 13 ------------- src/fs/explorer/mod.rs | 9 ++------- src/fs/mod.rs | 16 +--------------- src/host/mod.rs | 5 ----- src/utils/test_helpers.rs | 9 +++------ 8 files changed, 30 insertions(+), 86 deletions(-) diff --git a/src/filetransfer/ftp_transfer.rs b/src/filetransfer/ftp_transfer.rs index cd3e8e5..dc9b108 100644 --- a/src/filetransfer/ftp_transfer.rs +++ b/src/filetransfer/ftp_transfer.rs @@ -92,7 +92,6 @@ impl FtpFileTransfer { last_access_time: x.modified(), last_change_time: x.modified(), creation_time: x.modified(), - readonly: false, symlink: None, user: x.uid(), group: x.gid(), @@ -107,7 +106,6 @@ impl FtpFileTransfer { last_access_time: x.modified(), last_change_time: x.modified(), creation_time: x.modified(), - readonly: false, user: x.uid(), group: x.gid(), symlink: Self::get_symlink_entry(path, x.symlink()), @@ -149,7 +147,6 @@ impl FtpFileTransfer { creation_time: UNIX_EPOCH, user: None, group: None, - readonly: false, symlink: None, unix_pex: None, abs_path, @@ -775,11 +772,10 @@ mod tests { creation_time: UNIX_EPOCH, size: 0, ftype: Some(String::from("txt")), // File type - readonly: true, - symlink: None, // UNIX only - user: Some(0), // UNIX only - group: Some(0), // UNIX only - unix_pex: Some((6, 4, 4)), // UNIX only + symlink: None, // UNIX only + user: Some(0), // UNIX only + group: Some(0), // UNIX only + unix_pex: Some((6, 4, 4)), // UNIX only }); assert!(ftp .rename(&dummy, PathBuf::from("/a/b/c").as_path()) @@ -931,11 +927,10 @@ mod tests { creation_time: UNIX_EPOCH, size: 0, ftype: Some(String::from("txt")), // File type - readonly: true, - symlink: None, // UNIX only - user: Some(0), // UNIX only - group: Some(0), // UNIX only - unix_pex: Some((6, 4, 4)), // UNIX only + symlink: None, // UNIX only + user: Some(0), // UNIX only + group: Some(0), // UNIX only + unix_pex: Some((6, 4, 4)), // UNIX only }; let mut ftp: FtpFileTransfer = FtpFileTransfer::new(false); assert!(ftp.change_dir(Path::new("/tmp")).is_err()); diff --git a/src/filetransfer/scp_transfer.rs b/src/filetransfer/scp_transfer.rs index d98b3e3..478038a 100644 --- a/src/filetransfer/scp_transfer.rs +++ b/src/filetransfer/scp_transfer.rs @@ -218,7 +218,6 @@ impl ScpFileTransfer { last_change_time: mtime, last_access_time: mtime, creation_time: mtime, - readonly: false, symlink, user: uid, group: gid, @@ -232,7 +231,6 @@ impl ScpFileTransfer { creation_time: mtime, size: filesize, ftype: extension, - readonly: false, symlink, user: uid, group: gid, @@ -1125,11 +1123,10 @@ mod tests { creation_time: SystemTime::UNIX_EPOCH, size: 0, ftype: Some(String::from("txt")), // File type - readonly: true, - symlink: None, // UNIX only - user: Some(0), // UNIX only - group: Some(0), // UNIX only - unix_pex: Some((6, 4, 4)), // UNIX only + symlink: None, // UNIX only + user: Some(0), // UNIX only + group: Some(0), // UNIX only + unix_pex: Some((6, 4, 4)), // UNIX only }); assert!(client .rename(&dummy, PathBuf::from("/a/b/c").as_path()) @@ -1244,7 +1241,6 @@ mod tests { assert_eq!(entry.abs_path, PathBuf::from("/tmp/Cargo.toml")); assert_eq!(entry.unix_pex.unwrap(), (6, 4, 4)); assert_eq!(entry.size, 2056); - assert_eq!(entry.readonly, false); assert_eq!(entry.ftype.unwrap().as_str(), "toml"); assert!(entry.symlink.is_none()); // File (year) @@ -1260,7 +1256,6 @@ mod tests { assert_eq!(entry.abs_path, PathBuf::from("/tmp/CODE_OF_CONDUCT.md")); assert_eq!(entry.unix_pex.unwrap(), (6, 6, 6)); assert_eq!(entry.size, 3368); - assert_eq!(entry.readonly, false); assert_eq!(entry.ftype.unwrap().as_str(), "md"); assert!(entry.symlink.is_none()); // Directory @@ -1275,7 +1270,6 @@ mod tests { assert_eq!(entry.name.as_str(), "docs"); assert_eq!(entry.abs_path, PathBuf::from("/tmp/docs")); assert_eq!(entry.unix_pex.unwrap(), (7, 5, 5)); - assert_eq!(entry.readonly, false); assert!(entry.symlink.is_none()); // Short metadata assert!(client @@ -1323,11 +1317,10 @@ mod tests { creation_time: SystemTime::UNIX_EPOCH, size: 0, ftype: Some(String::from("txt")), // File type - readonly: true, - symlink: None, // UNIX only - user: Some(0), // UNIX only - group: Some(0), // UNIX only - unix_pex: Some((6, 4, 4)), // UNIX only + symlink: None, // UNIX only + user: Some(0), // UNIX only + group: Some(0), // UNIX only + unix_pex: Some((6, 4, 4)), // UNIX only }; let mut scp: ScpFileTransfer = ScpFileTransfer::new(SshKeyStorage::empty()); assert!(scp.change_dir(Path::new("/tmp")).is_err()); diff --git a/src/filetransfer/sftp_transfer.rs b/src/filetransfer/sftp_transfer.rs index 64050b3..398cfc6 100644 --- a/src/filetransfer/sftp_transfer.rs +++ b/src/filetransfer/sftp_transfer.rs @@ -178,7 +178,6 @@ impl SftpFileTransfer { last_change_time: mtime, last_access_time: atime, creation_time: SystemTime::UNIX_EPOCH, - readonly: false, symlink, user: uid, group: gid, @@ -192,7 +191,6 @@ impl SftpFileTransfer { last_change_time: mtime, last_access_time: atime, creation_time: SystemTime::UNIX_EPOCH, - readonly: false, symlink, user: uid, group: gid, @@ -923,11 +921,10 @@ mod tests { creation_time: SystemTime::UNIX_EPOCH, size: 0, ftype: Some(String::from("txt")), // File type - readonly: true, - symlink: None, // UNIX only - user: Some(0), // UNIX only - group: Some(0), // UNIX only - unix_pex: Some((6, 4, 4)), // UNIX only + symlink: None, // UNIX only + user: Some(0), // UNIX only + group: Some(0), // UNIX only + unix_pex: Some((6, 4, 4)), // UNIX only }); assert!(client .rename(&dummy, PathBuf::from("/a/b/c").as_path()) @@ -1072,11 +1069,10 @@ mod tests { creation_time: SystemTime::UNIX_EPOCH, size: 0, ftype: Some(String::from("txt")), // File type - readonly: true, - symlink: None, // UNIX only - user: Some(0), // UNIX only - group: Some(0), // UNIX only - unix_pex: Some((6, 4, 4)), // UNIX only + symlink: None, // UNIX only + user: Some(0), // UNIX only + group: Some(0), // UNIX only + unix_pex: Some((6, 4, 4)), // UNIX only }; let mut sftp: SftpFileTransfer = SftpFileTransfer::new(SshKeyStorage::empty()); assert!(sftp.change_dir(Path::new("/tmp")).is_err()); diff --git a/src/fs/explorer/formatter.rs b/src/fs/explorer/formatter.rs index 54ba14d..f630b21 100644 --- a/src/fs/explorer/formatter.rs +++ b/src/fs/explorer/formatter.rs @@ -552,7 +552,6 @@ mod tests { last_access_time: t_now, creation_time: t_now, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: Some(0), // UNIX only @@ -593,7 +592,6 @@ mod tests { last_access_time: t, creation_time: t, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: Some(0), // UNIX only @@ -624,7 +622,6 @@ mod tests { last_access_time: t, creation_time: t, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: Some(0), // UNIX only @@ -655,7 +652,6 @@ mod tests { last_access_time: t, creation_time: t, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: Some(0), // UNIX only @@ -686,7 +682,6 @@ mod tests { last_access_time: t, creation_time: t, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: None, // UNIX only @@ -723,7 +718,6 @@ mod tests { last_change_time: t_now, last_access_time: t_now, creation_time: t_now, - readonly: false, symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -752,7 +746,6 @@ mod tests { last_change_time: t_now, last_access_time: t_now, creation_time: t_now, - readonly: false, symlink: None, // UNIX only user: None, // UNIX only group: Some(0), // UNIX only @@ -789,7 +782,6 @@ mod tests { last_access_time: t, creation_time: t, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: None, // UNIX only @@ -802,7 +794,6 @@ mod tests { last_change_time: t, last_access_time: t, creation_time: t, - readonly: false, symlink: Some(Box::new(pointer)), // UNIX only user: None, // UNIX only group: None, // UNIX only @@ -821,7 +812,6 @@ mod tests { last_change_time: t, last_access_time: t, creation_time: t, - readonly: false, symlink: None, // UNIX only user: None, // UNIX only group: None, // UNIX only @@ -841,7 +831,6 @@ mod tests { last_access_time: t, creation_time: t, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: None, // UNIX only @@ -855,7 +844,6 @@ mod tests { last_access_time: t, creation_time: t, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: Some(Box::new(pointer)), // UNIX only user: None, // UNIX only @@ -876,7 +864,6 @@ mod tests { last_access_time: t, creation_time: t, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: None, // UNIX only diff --git a/src/fs/explorer/mod.rs b/src/fs/explorer/mod.rs index 27b74f8..5d98603 100644 --- a/src/fs/explorer/mod.rs +++ b/src/fs/explorer/mod.rs @@ -586,7 +586,6 @@ mod tests { last_access_time: t, creation_time: t, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: Some(0), // UNIX only @@ -670,8 +669,7 @@ mod tests { last_access_time: t_now, creation_time: t_now, size: 64, - ftype: None, // File type - readonly: false, + ftype: None, // File type symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -683,7 +681,6 @@ mod tests { last_change_time: t_now, last_access_time: t_now, creation_time: t_now, - readonly: false, symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -702,8 +699,7 @@ mod tests { last_access_time: t_now, creation_time: t_now, size: size, - ftype: None, // File type - readonly: false, + ftype: None, // File type symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -715,7 +711,6 @@ mod tests { last_change_time: t_now, last_access_time: t_now, creation_time: t_now, - readonly: false, symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only diff --git a/src/fs/mod.rs b/src/fs/mod.rs index 07e06a9..cb21fdd 100644 --- a/src/fs/mod.rs +++ b/src/fs/mod.rs @@ -52,7 +52,6 @@ pub struct FsDirectory { pub last_change_time: SystemTime, pub last_access_time: SystemTime, pub creation_time: SystemTime, - pub readonly: bool, pub symlink: Option>, // UNIX only pub user: Option, // UNIX only pub group: Option, // UNIX only @@ -71,8 +70,7 @@ pub struct FsFile { pub last_access_time: SystemTime, pub creation_time: SystemTime, pub size: usize, - pub ftype: Option, // File type - pub readonly: bool, + pub ftype: Option, // File type pub symlink: Option>, // UNIX only pub user: Option, // UNIX only pub group: Option, // UNIX only @@ -264,7 +262,6 @@ mod tests { last_change_time: t_now, last_access_time: t_now, creation_time: t_now, - readonly: false, symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -296,7 +293,6 @@ mod tests { last_access_time: t_now, creation_time: t_now, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: Some(0), // UNIX only @@ -330,7 +326,6 @@ mod tests { last_access_time: t_now, creation_time: t_now, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: Some(0), // UNIX only @@ -350,7 +345,6 @@ mod tests { last_change_time: t_now, last_access_time: t_now, creation_time: t_now, - readonly: false, symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -369,7 +363,6 @@ mod tests { last_access_time: t_now, creation_time: t_now, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: Some(0), // UNIX only @@ -384,7 +377,6 @@ mod tests { last_access_time: t_now, creation_time: t_now, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: Some(0), // UNIX only @@ -398,7 +390,6 @@ mod tests { last_change_time: t_now, last_access_time: t_now, creation_time: t_now, - readonly: false, symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -418,7 +409,6 @@ mod tests { last_access_time: t_now, creation_time: t_now, size: 8192, - readonly: false, ftype: Some(String::from("txt")), symlink: None, // UNIX only user: Some(0), // UNIX only @@ -437,7 +427,6 @@ mod tests { last_change_time: t_now, last_access_time: t_now, creation_time: t_now, - readonly: false, symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -457,7 +446,6 @@ mod tests { last_change_time: t_now, last_access_time: t_now, creation_time: t_now, - readonly: false, symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -469,7 +457,6 @@ mod tests { last_change_time: t_now, last_access_time: t_now, creation_time: t_now, - readonly: false, symlink: Some(Box::new(entry_target)), user: Some(0), group: Some(0), @@ -482,7 +469,6 @@ mod tests { last_access_time: t_now, creation_time: t_now, size: 8, - readonly: false, ftype: None, symlink: Some(Box::new(entry_child)), user: Some(0), diff --git a/src/host/mod.rs b/src/host/mod.rs index f9913de..9eb434a 100644 --- a/src/host/mod.rs +++ b/src/host/mod.rs @@ -461,7 +461,6 @@ impl Localhost { last_change_time: attr.modified().unwrap_or(SystemTime::UNIX_EPOCH), last_access_time: attr.accessed().unwrap_or(SystemTime::UNIX_EPOCH), creation_time: attr.created().unwrap_or(SystemTime::UNIX_EPOCH), - readonly: attr.permissions().readonly(), symlink: match fs::read_link(path.as_path()) { Ok(p) => match self.stat(p.as_path()) { Ok(entry) => Some(Box::new(entry)), @@ -484,7 +483,6 @@ impl Localhost { last_change_time: attr.modified().unwrap_or(SystemTime::UNIX_EPOCH), last_access_time: attr.accessed().unwrap_or(SystemTime::UNIX_EPOCH), creation_time: attr.created().unwrap_or(SystemTime::UNIX_EPOCH), - readonly: attr.permissions().readonly(), size: attr.len() as usize, ftype: extension, symlink: match fs::read_link(path.as_path()) { @@ -506,7 +504,6 @@ impl Localhost { /// /// Stat file and create a FsEntry #[cfg(target_os = "windows")] - #[cfg(not(tarpaulin_include))] pub fn stat(&self, path: &Path) -> Result { let path: PathBuf = self.to_abs_path(path); info!("Stating file {}", path.display()); @@ -530,7 +527,6 @@ impl Localhost { last_change_time: attr.modified().unwrap_or(SystemTime::UNIX_EPOCH), last_access_time: attr.accessed().unwrap_or(SystemTime::UNIX_EPOCH), creation_time: attr.created().unwrap_or(SystemTime::UNIX_EPOCH), - readonly: attr.permissions().readonly(), symlink: match fs::read_link(path.as_path()) { Ok(p) => match self.stat(p.as_path()) { Ok(entry) => Some(Box::new(entry)), @@ -554,7 +550,6 @@ impl Localhost { last_change_time: attr.modified().unwrap_or(SystemTime::UNIX_EPOCH), last_access_time: attr.accessed().unwrap_or(SystemTime::UNIX_EPOCH), creation_time: attr.created().unwrap_or(SystemTime::UNIX_EPOCH), - readonly: attr.permissions().readonly(), size: attr.len() as usize, ftype: extension, symlink: match fs::read_link(path.as_path()) { diff --git a/src/utils/test_helpers.rs b/src/utils/test_helpers.rs index 45239c8..8706900 100644 --- a/src/utils/test_helpers.rs +++ b/src/utils/test_helpers.rs @@ -53,8 +53,7 @@ pub fn create_sample_file_entry() -> (FsFile, NamedTempFile) { last_access_time: SystemTime::UNIX_EPOCH, creation_time: SystemTime::UNIX_EPOCH, size: 127, - ftype: None, // File type - readonly: false, + ftype: None, // File type symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -162,7 +161,6 @@ pub fn make_fsentry(path: PathBuf, is_dir: bool) -> FsEntry { last_change_time: SystemTime::UNIX_EPOCH, last_access_time: SystemTime::UNIX_EPOCH, creation_time: SystemTime::UNIX_EPOCH, - readonly: false, symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -175,8 +173,7 @@ pub fn make_fsentry(path: PathBuf, is_dir: bool) -> FsEntry { last_access_time: SystemTime::UNIX_EPOCH, creation_time: SystemTime::UNIX_EPOCH, size: 127, - ftype: None, // File type - readonly: false, + ftype: None, // File type symlink: None, // UNIX only user: Some(0), // UNIX only group: Some(0), // UNIX only @@ -200,7 +197,7 @@ mod test { #[test] fn test_utils_test_helpers_sample_file() { let (file, _) = create_sample_file_entry(); - assert_eq!(file.readonly, false); + assert!(file.symlink.is_none()); } #[test]