From 24f3ed3fccb6b4321fefb9f1b3fdb0c1067f6a26 Mon Sep 17 00:00:00 2001 From: "[Stephen D. Van Hooser]" <[vanhoosr@brandeis.edu]> Date: Wed, 3 Feb 2016 18:02:22 -0500 Subject: paramiko.sftp_file.prefetch now backwards compatible --- paramiko/sftp_file.py | 8 ++++++-- sites/www/changelog.rst | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index fe0f8c79..425a469a 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -378,8 +378,8 @@ class SFTPFile (BufferedFile): .. versionadded:: 1.5 """ self.pipelined = pipelined - - def prefetch(self, file_size): + + def prefetch(self, file_size=None): """ Pre-fetch the remaining contents of this file in anticipation of future `.read` calls. If reading the entire file, pre-fetching can @@ -393,6 +393,10 @@ class SFTPFile (BufferedFile): .. versionadded:: 1.5.1 """ + + if file_size is None: + file_size = self.stat().st_size; + # queue up async reads for the rest of the file chunks = [] n = self._realpos diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index eb89a4ee..dcad7fe6 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,8 @@ Changelog ========= +* :bug:`676` paramiko.sftp_file.prefetch is now backwards compatible with + previous versions of paramiko (1.15 to 1.5) * :bug:`577` (via :issue:`578`; should also fix :issue:`718`, :issue:`560`) Fix stalled/hung SFTP downloads by cleaning up some threading lock issues. Thanks to Stephen C. Pope for the patch. -- cgit v1.2.3 From c36dc6127cf3b651f64b84de2ff5c07554507963 Mon Sep 17 00:00:00 2001 From: "[Stephen D. Van Hooser]" <[vanhoosr@brandeis.edu]> Date: Wed, 3 Feb 2016 18:19:19 -0500 Subject: paramiko.sftp_file.prefetch now backwards compatible --- paramiko/sftp_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index 425a469a..8920dc29 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -395,7 +395,7 @@ class SFTPFile (BufferedFile): """ if file_size is None: - file_size = self.stat().st_size; + file_size = self.stat().st_size; # queue up async reads for the rest of the file chunks = [] -- cgit v1.2.3 From 8390ce1d94ae76a279142b16b72542bcd25c5964 Mon Sep 17 00:00:00 2001 From: "[Stephen D. Van Hooser]" <[vanhoosr@brandeis.edu]> Date: Wed, 3 Feb 2016 18:23:18 -0500 Subject: paramiko.sftp_file.prefetch now backwards compatible --- paramiko/sftp_file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index 8920dc29..a29a7d79 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -394,7 +394,7 @@ class SFTPFile (BufferedFile): .. versionadded:: 1.5.1 """ - if file_size is None: + if file_size is None: file_size = self.stat().st_size; # queue up async reads for the rest of the file -- cgit v1.2.3 From ab8448de4232d91915f51a8a26adfffa8ca05aa8 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Mon, 25 Apr 2016 10:10:24 -0700 Subject: Expand SFTPFile.prefetch docstring re #562, re #677 --- paramiko/sftp_file.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/paramiko/sftp_file.py b/paramiko/sftp_file.py index a29a7d79..8d147342 100644 --- a/paramiko/sftp_file.py +++ b/paramiko/sftp_file.py @@ -391,9 +391,21 @@ class SFTPFile (BufferedFile): data may be read in a random order (using `.seek`); chunks of the buffer that haven't been read will continue to be buffered. + :param int file_size: + When this is ``None`` (the default), this method calls `stat` to + determine the remote file size. In some situations, doing so can + cause exceptions or hangs (see `#562 + `_); as a + workaround, one may call `stat` explicitly and pass its value in + via this parameter. + .. versionadded:: 1.5.1 + .. versionchanged:: 1.16.0 + The ``file_size`` parameter was added (with no default value). + .. versionchanged:: 1.16.1 + The ``file_size`` parameter was made optional for backwards + compatibility. """ - if file_size is None: file_size = self.stat().st_size; -- cgit v1.2.3 From 3b8ebc9292f22aaeeb3979260cd91a2969fff166 Mon Sep 17 00:00:00 2001 From: Jeff Forcier Date: Mon, 25 Apr 2016 10:13:08 -0700 Subject: Reword/link changelog re #677, re #676 --- sites/www/changelog.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index dcad7fe6..0371e137 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,8 +2,11 @@ Changelog ========= -* :bug:`676` paramiko.sftp_file.prefetch is now backwards compatible with - previous versions of paramiko (1.15 to 1.5) +* :bug:`676` (via :issue:`677`) Fix a backwards incompatibility issue that + cropped up in `SFTPFile.prefetch <~paramiko.sftp_file.prefetch>` re: the + erroneously non-optional ``file_size`` parameter. Should only affect users + who manually call ``prefetch``. Thanks to ``@stevevanhooser`` for catch & + patch. * :bug:`577` (via :issue:`578`; should also fix :issue:`718`, :issue:`560`) Fix stalled/hung SFTP downloads by cleaning up some threading lock issues. Thanks to Stephen C. Pope for the patch. -- cgit v1.2.3