Removed unused readonly attribute for FsEntry

This commit is contained in:
veeso
2021-08-23 17:18:27 +02:00
parent 8a0f190474
commit 32ab0267fb
8 changed files with 30 additions and 86 deletions

View File

@@ -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,7 +772,6 @@ 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
@@ -931,7 +927,6 @@ 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

View File

@@ -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,7 +1123,6 @@ 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
@@ -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,7 +1317,6 @@ 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

View File

@@ -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,7 +921,6 @@ 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
@@ -1072,7 +1069,6 @@ 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

View File

@@ -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

View File

@@ -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
@@ -671,7 +670,6 @@ mod tests {
creation_time: t_now,
size: 64,
ftype: None, // File type
readonly: false,
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
@@ -703,7 +700,6 @@ mod tests {
creation_time: t_now,
size: size,
ftype: None, // File type
readonly: false,
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

View File

@@ -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<Box<FsEntry>>, // UNIX only
pub user: Option<u32>, // UNIX only
pub group: Option<u32>, // UNIX only
@@ -72,7 +71,6 @@ pub struct FsFile {
pub creation_time: SystemTime,
pub size: usize,
pub ftype: Option<String>, // File type
pub readonly: bool,
pub symlink: Option<Box<FsEntry>>, // UNIX only
pub user: Option<u32>, // UNIX only
pub group: Option<u32>, // 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),

View File

@@ -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<FsEntry, HostError> {
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()) {

View File

@@ -54,7 +54,6 @@ pub fn create_sample_file_entry() -> (FsFile, NamedTempFile) {
creation_time: SystemTime::UNIX_EPOCH,
size: 127,
ftype: None, // File type
readonly: false,
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
@@ -176,7 +174,6 @@ pub fn make_fsentry(path: PathBuf, is_dir: bool) -> FsEntry {
creation_time: SystemTime::UNIX_EPOCH,
size: 127,
ftype: None, // File type
readonly: false,
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]