Commit 18e111c6 authored by Harald Sitter's avatar Harald Sitter
Browse files

sftp: stop using an entire attr ptr in GetRequest

we only need the maximum length we can read, beyond that it has no use.
how the caller gets ahold of the maximum is entirely not a concern of
parent 024fa38f
......@@ -1611,7 +1611,7 @@ Result SFTPInternal::sftpGet(const QUrl &url, KIO::fileoffset_t offset, int fd)
bytesread = 0;
SFTPInternal::GetRequest request(file,;
SFTPInternal::GetRequest request(file, sb->size);
for (;;) {
// Enqueue get requests
......@@ -2482,9 +2482,9 @@ void SFTPInternal::slave_status() {
q->slaveStatus((mConnected ? mHost : QString()), mConnected);
SFTPInternal::GetRequest::GetRequest(sftp_file file, sftp_attributes sb, ushort maxPendingRequests)
SFTPInternal::GetRequest::GetRequest(sftp_file file, size_t size, ushort maxPendingRequests)
: m_file(file)
, m_sb(sb)
, m_size(size)
, m_maxPendingRequests(maxPendingRequests)
......@@ -2509,7 +2509,7 @@ bool SFTPInternal::GetRequest::enqueueChunks()
if (m_file->offset >= m_sb->size) {
if (m_file->offset >= m_size) {
// Do not add any more chunks if the offset is larger than the given file size.
// However this is done after adding a request as the remote file size may
// have changed in the meantime.
......@@ -167,13 +167,13 @@ private: // Private variables
* Requests do not take ownership of the SFTP pointers! The caller is
* responsible for freeing them.
* @param file the sftp_file object which should be transferred.
* @param sb the attributes of that sftp_file object.
* @param size the total size of the file.
* @param maxPendingRequests the maximum number of parallel requests to start with.
* The more are pending the higher the potential memory
* foot print, however if the connection allows it
* we'll get better throughput.
GetRequest(sftp_file file, sftp_attributes sb, ushort maxPendingRequests = 128);
GetRequest(sftp_file file, uint64_t size, ushort maxPendingRequests = 128);
* Removes all pending requests and closes the SFTP channel and attributes
* in order to avoid memory leaks.
......@@ -203,7 +203,7 @@ private: // Private variables
sftp_file m_file;
sftp_attributes m_sb;
const uint64_t m_size; // size of file (max readable)
ushort m_maxPendingRequests;
QQueue<Request> m_pendingRequests;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment