Changed Callback for file transfer; mkdir using path instead of String

This commit is contained in:
ChristianVisintin
2020-11-28 10:49:58 +01:00
parent 4e25e4d7b4
commit 4dc82d2ebb
2 changed files with 12 additions and 12 deletions

View File

@@ -313,7 +313,7 @@ impl FileTransfer for SftpFileTransfer {
/// ### mkdir
///
/// Make directory
fn mkdir(&self, dir: String) -> Result<(), FileTransferError> {
fn mkdir(&self, dir: &Path) -> Result<(), FileTransferError> {
match self.sftp.as_ref() {
Some(sftp) => {
// Make directory
@@ -399,7 +399,7 @@ impl FileTransfer for SftpFileTransfer {
&self,
file_name: &Path,
file: &mut File,
prog_cb: Option<ProgressCallback>,
prog_cb: Option<Box<ProgressCallback>>,
) -> Result<(), FileTransferError> {
match self.sftp.as_ref() {
None => Err(FileTransferError::UninitializedSession),
@@ -429,7 +429,7 @@ impl FileTransfer for SftpFileTransfer {
return Err(FileTransferError::IoErr(err));
}
// Call callback
if let Some(cb) = prog_cb {
if let Some(ref cb) = prog_cb {
cb(total_bytes_written, file_size);
}
}
@@ -452,7 +452,7 @@ impl FileTransfer for SftpFileTransfer {
&self,
file_name: &Path,
dest_file: &mut File,
prog_cb: Option<ProgressCallback>,
prog_cb: Option<Box<ProgressCallback>>,
) -> Result<(), FileTransferError> {
match self.sftp.as_ref() {
None => Err(FileTransferError::UninitializedSession),
@@ -487,7 +487,7 @@ impl FileTransfer for SftpFileTransfer {
return Err(FileTransferError::IoErr(err));
}
// Call callback
if let Some(cb) = prog_cb {
if let Some(ref cb) = prog_cb {
cb(total_bytes_written, file_size);
}
}
@@ -699,7 +699,7 @@ mod tests {
.recv_file(
PathBuf::from("readme.txt").as_path(),
&mut dst_file_hnd,
Some(progress_callback)
Some(Box::new(progress_callback))
)
.is_ok());
// Disconnect
@@ -733,7 +733,7 @@ mod tests {
.recv_file(
PathBuf::from("omar.txt").as_path(),
&mut dst_file_hnd,
Some(progress_callback)
Some(Box::new(progress_callback))
)
.is_err());
// Disconnect
@@ -770,7 +770,7 @@ mod tests {
.recv_file(
PathBuf::from("readme.txt").as_path(),
&mut dst_file_hnd,
Some(progress_callback)
Some(Box::new(progress_callback))
)
.is_err());
// Disconnect