mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
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
This commit is contained in:
@@ -19,6 +19,7 @@ FIXME: Released on ???
|
|||||||
- Added connection timeout to 30 seconds to SFTP/SCP clients and improved name lookup system.
|
- Added connection timeout to 30 seconds to SFTP/SCP clients and improved name lookup system.
|
||||||
- Bugfix:
|
- Bugfix:
|
||||||
- Solved index in explorer files list which was no more kept after 0.3.0
|
- 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
|
## 0.3.0
|
||||||
|
|
||||||
|
|||||||
@@ -793,7 +793,13 @@ impl FileTransfer for ScpFileTransfer {
|
|||||||
};
|
};
|
||||||
(mtime, atime)
|
(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))),
|
Ok(channel) => Ok(Box::new(BufWriter::with_capacity(65536, channel))),
|
||||||
Err(err) => Err(FileTransferError::new_ex(
|
Err(err) => Err(FileTransferError::new_ex(
|
||||||
FileTransferErrorType::ProtocolError,
|
FileTransferErrorType::ProtocolError,
|
||||||
|
|||||||
Reference in New Issue
Block a user