SCP File transfer: when listing directory entries, check if a symlink points to a directory or to a file

This commit is contained in:
veeso
2021-01-23 12:20:34 +01:00
parent 0c9ed38eb7
commit d99efb9de4
2 changed files with 13 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ FIXME: Released on
- Bugfix: - Bugfix:
- Solved file index in explorer files at start of termscp, in case the first entry is an hidden file - Solved file index in explorer files at start of termscp, in case the first entry is an hidden file
- SCP File transfer: when listing directory entries, check if a symlink points to a directory or to a file
## 0.3.1 ## 0.3.1

View File

@@ -83,7 +83,8 @@ impl ScpFileTransfer {
} }
// Collect metadata // Collect metadata
// Get if is directory and if is symlink // Get if is directory and if is symlink
let (is_dir, is_symlink): (bool, bool) = match metadata.get(1).unwrap().as_str() { let (mut is_dir, is_symlink): (bool, bool) = match metadata.get(1).unwrap().as_str()
{
"-" => (false, false), "-" => (false, false),
"l" => (false, true), "l" => (false, true),
"d" => (true, false), "d" => (true, false),
@@ -135,12 +136,21 @@ impl ScpFileTransfer {
Err(_) => None, Err(_) => None,
}; };
// Get filesize // Get filesize
let filesize: usize = metadata.get(6).unwrap().as_str().parse::<usize>().unwrap_or(0); let filesize: usize = metadata
.get(6)
.unwrap()
.as_str()
.parse::<usize>()
.unwrap_or(0);
// Get link and name // Get link and name
let (file_name, symlink_path): (String, Option<PathBuf>) = match is_symlink { let (file_name, symlink_path): (String, Option<PathBuf>) = match is_symlink {
true => self.get_name_and_link(metadata.get(8).unwrap().as_str()), true => self.get_name_and_link(metadata.get(8).unwrap().as_str()),
false => (String::from(metadata.get(8).unwrap().as_str()), None), false => (String::from(metadata.get(8).unwrap().as_str()), None),
}; };
// Check if symlink points to a directory
if let Some(symlink_path) = symlink_path.as_ref() {
is_dir = symlink_path.is_dir();
}
// Get symlink // Get symlink
let symlink: Option<Box<FsEntry>> = match symlink_path { let symlink: Option<Box<FsEntry>> = match symlink_path {
None => None, None => None,