mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
SCP: fixed symlink not properly detected
This commit is contained in:
@@ -19,7 +19,12 @@
|
|||||||
|
|
||||||
Released on FIXME:
|
Released on FIXME:
|
||||||
|
|
||||||
|
- Enhancements:
|
||||||
|
- SCP file transfer:
|
||||||
|
- Added possibility to stat directories.
|
||||||
- Bugfix:
|
- Bugfix:
|
||||||
|
- [Issue 17](https://github.com/veeso/termscp/issues/17)
|
||||||
|
- SCP: fixed symlink not properly detected
|
||||||
- [Issue 10](https://github.com/veeso/termscp/issues/10): Fixed port not being loaded from bookmarks into gui
|
- [Issue 10](https://github.com/veeso/termscp/issues/10): Fixed port not being loaded from bookmarks into gui
|
||||||
- [Issue 9](https://github.com/veeso/termscp/issues/9): Fixed issues related to paths on remote when using Windows
|
- [Issue 9](https://github.com/veeso/termscp/issues/9): Fixed issues related to paths on remote when using Windows
|
||||||
- Dependencies:
|
- Dependencies:
|
||||||
@@ -38,6 +43,8 @@ Released on FIXME:
|
|||||||
|
|
||||||
Released on 27/03/2021
|
Released on 27/03/2021
|
||||||
|
|
||||||
|
> The UI refactoring update
|
||||||
|
|
||||||
- **New explorer features**:
|
- **New explorer features**:
|
||||||
- **Execute** a command pressing `X`. This feature is supported on both local and remote hosts (only SFTP/SCP protocols support this feature).
|
- **Execute** a command pressing `X`. This feature is supported on both local and remote hosts (only SFTP/SCP protocols support this feature).
|
||||||
- **Find**: search for files pressing `F` using wild matches.
|
- **Find**: search for files pressing `F` using wild matches.
|
||||||
|
|||||||
@@ -165,9 +165,9 @@ impl ScpFileTransfer {
|
|||||||
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
|
// Check if file_name is '.' or '..'
|
||||||
if let Some(symlink_path) = symlink_path.as_ref() {
|
if file_name.as_str() == "." || file_name.as_str() == ".." {
|
||||||
is_dir = symlink_path.is_dir();
|
return Err(());
|
||||||
}
|
}
|
||||||
// Get symlink; PATH mustn't be equal to filename
|
// Get symlink; PATH mustn't be equal to filename
|
||||||
let symlink: Option<Box<FsEntry>> = match symlink_path {
|
let symlink: Option<Box<FsEntry>> = match symlink_path {
|
||||||
@@ -179,15 +179,18 @@ impl ScpFileTransfer {
|
|||||||
true => None,
|
true => None,
|
||||||
false => match self.stat(p.as_path()) {
|
false => match self.stat(p.as_path()) {
|
||||||
// If path match filename
|
// If path match filename
|
||||||
Ok(e) => Some(Box::new(e)),
|
Ok(e) => {
|
||||||
|
// If e is a directory, set is_dir to true
|
||||||
|
if e.is_dir() {
|
||||||
|
is_dir = true;
|
||||||
|
}
|
||||||
|
Some(Box::new(e))
|
||||||
|
}
|
||||||
Err(_) => None, // Ignore errors
|
Err(_) => None, // Ignore errors
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// Check if file_name is '.' or '..'
|
// Re-check if is directory
|
||||||
if file_name.as_str() == "." || file_name.as_str() == ".." {
|
|
||||||
return Err(());
|
|
||||||
}
|
|
||||||
let mut abs_path: PathBuf = PathBuf::from(path);
|
let mut abs_path: PathBuf = PathBuf::from(path);
|
||||||
abs_path.push(file_name.as_str());
|
abs_path.push(file_name.as_str());
|
||||||
let abs_path: PathBuf = Self::resolve(abs_path.as_path());
|
let abs_path: PathBuf = Self::resolve(abs_path.as_path());
|
||||||
@@ -556,7 +559,7 @@ impl FileTransfer for ScpFileTransfer {
|
|||||||
let p: PathBuf = self.wrkdir.clone();
|
let p: PathBuf = self.wrkdir.clone();
|
||||||
match self.perform_shell_cmd_with_path(
|
match self.perform_shell_cmd_with_path(
|
||||||
p.as_path(),
|
p.as_path(),
|
||||||
format!("unset LANG; ls -la \"{}\"", path.display()).as_str(),
|
format!("unset LANG; ls -la \"{}/\"", path.display()).as_str(),
|
||||||
) {
|
) {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
// Split output by (\r)\n
|
// Split output by (\r)\n
|
||||||
@@ -703,12 +706,6 @@ impl FileTransfer for ScpFileTransfer {
|
|||||||
///
|
///
|
||||||
/// Stat file and return FsEntry
|
/// Stat file and return FsEntry
|
||||||
fn stat(&mut self, path: &Path) -> Result<FsEntry, FileTransferError> {
|
fn stat(&mut self, path: &Path) -> Result<FsEntry, FileTransferError> {
|
||||||
if path.is_dir() {
|
|
||||||
return Err(FileTransferError::new_ex(
|
|
||||||
FileTransferErrorType::UnsupportedFeature,
|
|
||||||
String::from("stat is not supported for directories"),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
let path: PathBuf = match path.is_absolute() {
|
let path: PathBuf = match path.is_absolute() {
|
||||||
true => PathBuf::from(path),
|
true => PathBuf::from(path),
|
||||||
false => {
|
false => {
|
||||||
@@ -720,10 +717,12 @@ impl FileTransfer for ScpFileTransfer {
|
|||||||
match self.is_connected() {
|
match self.is_connected() {
|
||||||
true => {
|
true => {
|
||||||
let p: PathBuf = self.wrkdir.clone();
|
let p: PathBuf = self.wrkdir.clone();
|
||||||
match self.perform_shell_cmd_with_path(
|
// make command; Directories require `-d` option
|
||||||
p.as_path(),
|
let cmd: String = match path.to_string_lossy().ends_with('/') {
|
||||||
format!("ls -l \"{}\"", path.display()).as_str(),
|
true => format!("ls -ld \"{}\"", path.display()),
|
||||||
) {
|
false => format!("ls -l \"{}\"", path.display()),
|
||||||
|
};
|
||||||
|
match self.perform_shell_cmd_with_path(p.as_path(), cmd.as_str()) {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
// Parse ls line
|
// Parse ls line
|
||||||
let parent: PathBuf = match path.as_path().parent() {
|
let parent: PathBuf = match path.as_path().parent() {
|
||||||
|
|||||||
Reference in New Issue
Block a user