diff options
author | Christopher Baines <mail@cbaines.net> | 2016-02-07 21:19:28 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2016-02-07 21:19:28 +0000 |
commit | 31b2fd0709f259961253b9cdc875ce7827abaa68 (patch) | |
tree | 863b7f1fe851d7183419916248591537a4b8b6c5 /paramiko/sftp_file.py | |
parent | bf855e6da326dba0c46f005eedc9f390c6c3b206 (diff) | |
download | python-paramiko-31b2fd0709f259961253b9cdc875ce7827abaa68.tar python-paramiko-31b2fd0709f259961253b9cdc875ce7827abaa68.tar.gz |
Imported Upstream version 1.16.0upstream/1.16.0upstream
Diffstat (limited to 'paramiko/sftp_file.py')
-rw-r--r-- | paramiko/sftp_file.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index d0a37da..c5b6548 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -379,7 +379,7 @@ class SFTPFile (BufferedFile): """ self.pipelined = pipelined - def prefetch(self): + def prefetch(self, file_size): """ Pre-fetch the remaining contents of this file in anticipation of future `.read` calls. If reading the entire file, pre-fetching can @@ -393,12 +393,11 @@ class SFTPFile (BufferedFile): .. versionadded:: 1.5.1 """ - size = self.stat().st_size # queue up async reads for the rest of the file chunks = [] n = self._realpos - while n < size: - chunk = min(self.MAX_REQUEST_SIZE, size - n) + while n < file_size: + chunk = min(self.MAX_REQUEST_SIZE, file_size - n) chunks.append((n, chunk)) n += chunk if len(chunks) > 0: |