diff --git a/CHANGELOG.md b/CHANGELOG.md index 868c191..db09900 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ FIXME: Released on ??? - Added connection timeout to 30 seconds to SFTP/SCP clients and improved name lookup system. - Bugfix: - Solved index in explorer files list which was no more kept after 0.3.0 + - SCP file transfer: fixed possible wrong file size when sending file, due to a possible incoherent size between the file explorer and the actual file size. ## 0.3.0 diff --git a/src/filetransfer/scp_transfer.rs b/src/filetransfer/scp_transfer.rs index 5b7ffda..13f1a43 100644 --- a/src/filetransfer/scp_transfer.rs +++ b/src/filetransfer/scp_transfer.rs @@ -793,7 +793,13 @@ impl FileTransfer for ScpFileTransfer { }; (mtime, atime) }; - match session.scp_send(file_name, mode, local.size as u64, Some(times)) { + // We need to get the size of local; NOTE: don't use the `size` attribute, since might be out of sync + let file_size: u64 = match std::fs::metadata(local.abs_path.as_path()) { + Ok(metadata) => metadata.len(), + Err(_) => local.size as u64, // NOTE: fallback to fsentry size + }; + // Send file + match session.scp_send(file_name, mode, file_size, Some(times)) { Ok(channel) => Ok(Box::new(BufWriter::with_capacity(65536, channel))), Err(err) => Err(FileTransferError::new_ex( FileTransferErrorType::ProtocolError,