mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Fixed scp transfer stat method
This commit is contained in:
@@ -619,6 +619,14 @@ impl FileTransfer for ScpFileTransfer {
|
|||||||
String::from("stat is not supported for directories"),
|
String::from("stat is not supported for directories"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
let path: PathBuf = match path.is_absolute() {
|
||||||
|
true => PathBuf::from(path),
|
||||||
|
false => {
|
||||||
|
let mut p: PathBuf = self.wrkdir.clone();
|
||||||
|
p.push(path);
|
||||||
|
p
|
||||||
|
}
|
||||||
|
};
|
||||||
match self.is_connected() {
|
match self.is_connected() {
|
||||||
true => {
|
true => {
|
||||||
let p: PathBuf = self.wrkdir.clone();
|
let p: PathBuf = self.wrkdir.clone();
|
||||||
@@ -628,7 +636,7 @@ impl FileTransfer for ScpFileTransfer {
|
|||||||
) {
|
) {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
// Parse ls line
|
// Parse ls line
|
||||||
let parent: PathBuf = match path.parent() {
|
let parent: PathBuf = match path.as_path().parent() {
|
||||||
Some(p) => PathBuf::from(p),
|
Some(p) => PathBuf::from(p),
|
||||||
None => {
|
None => {
|
||||||
return Err(FileTransferError::new_ex(
|
return Err(FileTransferError::new_ex(
|
||||||
@@ -637,7 +645,7 @@ impl FileTransfer for ScpFileTransfer {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match self.parse_ls_output(parent.as_path(), line.as_str()) {
|
match self.parse_ls_output(parent.as_path(), line.as_str().trim()) {
|
||||||
Ok(entry) => Ok(entry),
|
Ok(entry) => Ok(entry),
|
||||||
Err(_) => Err(FileTransferError::new(
|
Err(_) => Err(FileTransferError::new(
|
||||||
FileTransferErrorType::NoSuchFileOrDirectory,
|
FileTransferErrorType::NoSuchFileOrDirectory,
|
||||||
@@ -739,10 +747,7 @@ impl FileTransfer for ScpFileTransfer {
|
|||||||
/// This is necessary for some protocols such as FTP.
|
/// This is necessary for some protocols such as FTP.
|
||||||
/// You must call this method each time you want to finalize the write of the remote file.
|
/// You must call this method each time you want to finalize the write of the remote file.
|
||||||
fn on_sent(&mut self, _writable: Box<dyn Write>) -> Result<(), FileTransferError> {
|
fn on_sent(&mut self, _writable: Box<dyn Write>) -> Result<(), FileTransferError> {
|
||||||
if let Some(session) = self.session.as_ref() {
|
// Nothing to do
|
||||||
// Set blocking to false
|
|
||||||
session.set_blocking(false);
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -754,10 +759,7 @@ impl FileTransfer for ScpFileTransfer {
|
|||||||
/// This mighe be necessary for some protocols.
|
/// This mighe be necessary for some protocols.
|
||||||
/// You must call this method each time you want to finalize the read of the remote file.
|
/// You must call this method each time you want to finalize the read of the remote file.
|
||||||
fn on_recv(&mut self, _readable: Box<dyn Read>) -> Result<(), FileTransferError> {
|
fn on_recv(&mut self, _readable: Box<dyn Read>) -> Result<(), FileTransferError> {
|
||||||
if let Some(session) = self.session.as_ref() {
|
// Nothing to do
|
||||||
// Set blocking to false
|
|
||||||
session.set_blocking(false);
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user