From bbcf7687aa966d2d570b6b1840f98a4ddefd42ed Mon Sep 17 00:00:00 2001 From: Robey Pointer Date: Thu, 9 Mar 2006 00:22:17 -0800 Subject: [PATCH] [project @ robey@lag.net-20060309082217-438047d0007d5a5b] reads were being rounded up to an 8k buffer size, even with no buffering specified when the file was opened. i traced this back to the old ChannelFile where it worked correctly. fix to only buffer when asked to. --- paramiko/file.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/paramiko/file.py b/paramiko/file.py index 17782d8..6de2b9b 100644 --- a/paramiko/file.py +++ b/paramiko/file.py @@ -147,8 +147,11 @@ class BufferedFile (object): self._pos += len(result) return result while len(self._rbuffer) < size: + read_size = size - len(self._rbuffer) + if self._flags & _FLAG_BUFFERED: + read_size = max(self._bufsize, read_size) try: - new_data = self._read(max(self._bufsize, size - len(self._rbuffer))) + new_data = self._read(read_size) except EOFError: new_data = None if (new_data is None) or (len(new_data) == 0): @@ -205,7 +208,7 @@ class BufferedFile (object): return line n = size - len(line) else: - n = self._DEFAULT_BUFSIZE + n = self._bufsize if ('\n' in line) or ((self._flags & _FLAG_UNIVERSAL_NEWLINE) and ('\r' in line)): break try: