mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Copy command support for SFTP
This commit is contained in:
@@ -39,6 +39,7 @@ Released on FIXME: ??
|
|||||||
- Protocol input as first field in UI
|
- Protocol input as first field in UI
|
||||||
- Port is now updated to standard for selected protocol
|
- Port is now updated to standard for selected protocol
|
||||||
- when you change the protocol in the authentication form and the current port is standard (`< 1024`), the port will be automatically changed to default value for the selected protocol (e.g. current port: `123`, protocol is changes to `FTP`, port becomes `21`)
|
- when you change the protocol in the authentication form and the current port is standard (`< 1024`), the port will be automatically changed to default value for the selected protocol (e.g. current port: `123`, protocol is changes to `FTP`, port becomes `21`)
|
||||||
|
- Added **COPY** command to SFTP (Please note that Copy command is not supported by SFTP natively, so here it just uses the `cp` shell command as it does in SCP).
|
||||||
- Bugfix:
|
- Bugfix:
|
||||||
- Fixed wrong text wrap in log box
|
- Fixed wrong text wrap in log box
|
||||||
- Fixed error message not being shown after an upload failure
|
- Fixed error message not being shown after an upload failure
|
||||||
|
|||||||
@@ -729,7 +729,7 @@ impl FileTransfer for ScpFileTransfer {
|
|||||||
Some(p) => PathBuf::from(p),
|
Some(p) => PathBuf::from(p),
|
||||||
None => {
|
None => {
|
||||||
return Err(FileTransferError::new_ex(
|
return Err(FileTransferError::new_ex(
|
||||||
FileTransferErrorType::UnsupportedFeature,
|
FileTransferErrorType::DirStatFailed,
|
||||||
String::from("Path has no parent"),
|
String::from("Path has no parent"),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -437,11 +437,42 @@ impl FileTransfer for SftpFileTransfer {
|
|||||||
/// ### copy
|
/// ### copy
|
||||||
///
|
///
|
||||||
/// Copy file to destination
|
/// Copy file to destination
|
||||||
fn copy(&mut self, _src: &FsEntry, _dst: &Path) -> Result<(), FileTransferError> {
|
fn copy(&mut self, src: &FsEntry, dst: &Path) -> Result<(), FileTransferError> {
|
||||||
// SFTP doesn't support file copy
|
// NOTE: use SCP command to perform copy (UNSAFE)
|
||||||
Err(FileTransferError::new(
|
match self.is_connected() {
|
||||||
FileTransferErrorType::UnsupportedFeature,
|
true => {
|
||||||
))
|
let dst: PathBuf = self.get_abs_path(dst);
|
||||||
|
// Run `cp -rf`
|
||||||
|
match self.perform_shell_cmd_with_path(
|
||||||
|
format!(
|
||||||
|
"cp -rf \"{}\" \"{}\"; echo $?",
|
||||||
|
src.get_abs_path().display(),
|
||||||
|
dst.display()
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
|
) {
|
||||||
|
Ok(output) =>
|
||||||
|
// Check if output is 0
|
||||||
|
{
|
||||||
|
match output.as_str().trim() == "0" {
|
||||||
|
true => Ok(()), // File copied
|
||||||
|
false => Err(FileTransferError::new_ex(
|
||||||
|
// Could not copy file
|
||||||
|
FileTransferErrorType::FileCreateDenied,
|
||||||
|
format!("\"{}\"", dst.display()),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(FileTransferError::new_ex(
|
||||||
|
FileTransferErrorType::ProtocolError,
|
||||||
|
err.to_string(),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false => Err(FileTransferError::new(
|
||||||
|
FileTransferErrorType::UninitializedSession,
|
||||||
|
)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### list_dir
|
/// ### list_dir
|
||||||
|
|||||||
Reference in New Issue
Block a user